perf tools: Only increase index if perf_evsel__new_idx() succeeds

Signed-off-by: Taeung Song <treeze.taeung@gmail.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1485952447-7013-2-git-send-email-treeze.taeung@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Taeung Song 2017-02-01 21:34:04 +09:00 committed by Arnaldo Carvalho de Melo
parent d5c3a937e0
commit 75fc5ae5cc

View File

@ -310,10 +310,11 @@ __add_event(struct list_head *list, int *idx,
event_attr_init(attr);
evsel = perf_evsel__new_idx(attr, (*idx)++);
evsel = perf_evsel__new_idx(attr, *idx);
if (!evsel)
return NULL;
(*idx)++;
evsel->cpus = cpu_map__get(cpus);
evsel->own_cpus = cpu_map__get(cpus);