From patchwork Wed Sep 2 02:53:47 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wang Nan X-Patchwork-Id: 52951 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f197.google.com (mail-wi0-f197.google.com [209.85.212.197]) by patches.linaro.org (Postfix) with ESMTPS id 6BB022157D for ; Wed, 2 Sep 2015 02:54:29 +0000 (UTC) Received: by wiclp12 with SMTP id lp12sf1442708wic.0 for ; Tue, 01 Sep 2015 19:54:28 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-type:sender:precedence :list-id:x-original-sender:x-original-authentication-results :mailing-list:list-post:list-help:list-archive:list-unsubscribe; bh=BxvRNt/S5oNII1ClXF9e+L1P5ucXBID31EewuiKi/sM=; b=YwQYxaSW9jXuRqOuBJk4xcwhqeI3vb9Ve4MzAOLnBrNaJkZsyw4iQb4Yn4dQT2GV7f ORrLaNbrCr3PJmHsqojZjhacFNxcug4hOVjLaFMMAhA81LVs6C6xPLTK1SciwVIYFGF+ yoOqJjd89CrhzMH/GGgp9OG1l02Rx52GiGb+HMlrHi2ck8IllLh5Pu9K799eHHDDI1Iq wKZmOVxpy/dBUHnpCkuiTVyPZP5rjuDhiTobLy6O1ZrKSfHFu+f6GKngn3GWG7BfRYFx AvkY+I9WAIz8ayHPHmm2/f+oU2I2ozVaACXoZODLBVFuplA/PF/sRPPXJYMwY+w+fsa3 3DPw== X-Gm-Message-State: ALoCoQnokghwvV7aGauU7w0E30hzzniLKQ4KcQXAsTo2qquDvN2PFCAx80CE0f4QYGHRsYGhvZFr X-Received: by 10.112.144.99 with SMTP id sl3mr805721lbb.12.1441162468300; Tue, 01 Sep 2015 19:54:28 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.20.72 with SMTP id l8ls32733lae.9.gmail; Tue, 01 Sep 2015 19:54:28 -0700 (PDT) X-Received: by 10.152.120.198 with SMTP id le6mr14844131lab.38.1441162468128; Tue, 01 Sep 2015 19:54:28 -0700 (PDT) Received: from mail-la0-f54.google.com (mail-la0-f54.google.com. [209.85.215.54]) by mx.google.com with ESMTPS id v9si18334991laj.94.2015.09.01.19.54.27 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 01 Sep 2015 19:54:27 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) client-ip=209.85.215.54; Received: by lanb10 with SMTP id b10so12323773lan.3 for ; Tue, 01 Sep 2015 19:54:27 -0700 (PDT) X-Received: by 10.152.18.164 with SMTP id x4mr14923805lad.35.1441162467504; Tue, 01 Sep 2015 19:54:27 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.164.42 with SMTP id yn10csp247768lbb; Tue, 1 Sep 2015 19:54:26 -0700 (PDT) X-Received: by 10.66.145.195 with SMTP id sw3mr52246095pab.72.1441162466358; Tue, 01 Sep 2015 19:54:26 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id dk5si33075726pbc.22.2015.09.01.19.54.25; Tue, 01 Sep 2015 19:54:26 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751908AbbIBCyX (ORCPT + 28 others); Tue, 1 Sep 2015 22:54:23 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:18546 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751240AbbIBCyW (ORCPT ); Tue, 1 Sep 2015 22:54:22 -0400 Received: from 172.24.1.50 (EHLO SZXEML424-HUB.china.huawei.com) ([172.24.1.50]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BMF07941; Wed, 02 Sep 2015 10:54:03 +0800 (CST) Received: from linux-4hy3.site (10.107.193.248) by SZXEML424-HUB.china.huawei.com (10.82.67.153) with Microsoft SMTP Server id 14.3.235.1; Wed, 2 Sep 2015 10:53:54 +0800 From: Wang Nan To: CC: , Wang Nan , "Alexei Starovoitov" , Jiri Olsa , "Masami Hiramatsu" , Namhyung Kim , Zefan Li , Subject: [PATCH] perf tools: Don't set leader if parser doesn't collect an evsel Date: Wed, 2 Sep 2015 02:53:47 +0000 Message-ID: <1441162427-114014-1-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1440822125-52691-3-git-send-email-wangnan0@huawei.com> References: <1440822125-52691-3-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A090204.55E664CC.00A5, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: cd83058d3d44229fdc34dbe9c91ed687 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: wangnan0@huawei.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.54 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Similar to patch 'perf tools: Don't set cmdline_group_boundary if no evsel is collected', in case when parser collects no evsel (at this point it shouldn't happen), parse_events__set_leader() is not safe. This patch checks list_empty becore calling __perf_evlist__set_leader() for safty reason. Signed-off-by: Wang Nan Cc: Arnaldo Carvalho de Melo Cc: Alexei Starovoitov Cc: Jiri Olsa Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Zefan Li Cc: pi3orama@163.com Reviewed-by: Masami Hiramatsu Acked-by: Jiri Olsa --- I'd like to queue this patch into my next pull request. Since it is not a real bug, it may be dropped. --- tools/perf/util/parse-events.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index f2c0317..836d226 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -793,6 +793,9 @@ void parse_events__set_leader(char *name, struct list_head *list) { struct perf_evsel *leader; + if (list_empty(list)) + return; + __perf_evlist__set_leader(list); leader = list_entry(list->next, struct perf_evsel, node); leader->group_name = name ? strdup(name) : NULL;