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.

[1]: 
http://lkml.kernel.org/n/1436445342-1402-19-git-send-email-wangn...@huawei.com

Signed-off-by: Wang Nan <wangn...@huawei.com>
Cc: Alexei Starovoitov <a...@plumgrid.com>
Cc: Masami Hiramatsu <masami.hiramatsu...@hitachi.com>
Cc: Namhyung Kim <namhy...@kernel.org>
Cc: Zefan Li <lize...@huawei.com>
Cc: pi3or...@163.com
Cc: Arnaldo Carvalho de Melo <a...@redhat.com>
---
 tools/perf/util/parse-events.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
index cce3e43..02609da 100644
--- a/tools/perf/util/parse-events.c
+++ b/tools/perf/util/parse-events.c
@@ -1171,9 +1171,11 @@ int parse_events(struct perf_evlist *evlist, const char 
*str,
 
                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;
 
+               if (entries > 0) {
+                       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 majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to