Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752031AbbH1GVe (ORCPT ); Fri, 28 Aug 2015 02:21:34 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:47521 "EHLO szxga03-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751981AbbH1GVb (ORCPT ); Fri, 28 Aug 2015 02:21:31 -0400 From: Wang Nan To: CC: , , , , , , , , , , , , , Wang Nan Subject: [PATCH 02/32] perf tools: Don't set cmdline_group_boundary if no evsel is collected Date: Fri, 28 Aug 2015 06:20:19 +0000 Message-ID: <1440742821-44548-3-git-send-email-wangnan0@huawei.com> X-Mailer: git-send-email 1.8.3.4 In-Reply-To: <1440742821-44548-1-git-send-email-wangnan0@huawei.com> References: <1440742821-44548-1-git-send-email-wangnan0@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.107.193.248] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020202.55DFFDD3.00D7,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: e0682bb47936c2550a026b521a0ef617 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1809 Lines: 52 If parse_events__scanner() collects no entry, perf_evlist__last(evlist) is invalid. Then setting of cmdline_group_boundary touches invalid. It could happend in currect BPF implementation. See [1]. Although it can be fixed, for safety reason it whould be better to introduce this check. Instead of checking number of entries, check data.list instead, so we can add dummy evsel here. [1]: http://lkml.kernel.org/n/1436445342-1402-19-git-send-email-wangnan0@huawei.com Signed-off-by: Wang Nan Cc: Alexei Starovoitov Cc: Masami Hiramatsu Cc: Namhyung Kim Cc: Zefan Li Cc: pi3orama@163.com Cc: Arnaldo Carvalho de Melo --- tools/perf/util/parse-events.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c index d826e6f..14cd7e3 100644 --- a/tools/perf/util/parse-events.c +++ b/tools/perf/util/parse-events.c @@ -1143,10 +1143,14 @@ int parse_events(struct perf_evlist *evlist, const char *str, int entries = data.idx - evlist->nr_entries; struct perf_evsel *last; + if (!list_empty(&data.list)) { + last = list_entry(data.list.prev, + struct perf_evsel, node); + last->cmdline_group_boundary = true; + } + perf_evlist__splice_list_tail(evlist, &data.list, entries); evlist->nr_groups += data.nr_groups; - last = perf_evlist__last(evlist); - last->cmdline_group_boundary = true; return 0; } -- 1.8.3.4 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/