perf parse-event: Release cpu_map refcount if evsel alloc failed
authorNamhyung Kim <namhyung@kernel.org>
Thu, 17 Sep 2020 06:02:18 +0000 (15:02 +0900)
committerArnaldo Carvalho de Melo <acme@redhat.com>
Thu, 17 Sep 2020 16:28:15 +0000 (13:28 -0300)
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Stephane Eranian <eranian@google.com>
Link: http://lore.kernel.org/lkml/20200917060219.1287863-1-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
tools/perf/util/parse-events.c

index 4c6b3d287d54e6ca26a04401a6197312eeac20de..fbe0d3143353dd481f84a84b5c1b0232464582ef 100644 (file)
@@ -360,8 +360,10 @@ __add_event(struct list_head *list, int *idx,
                event_attr_init(attr);
 
        evsel = evsel__new_idx(attr, *idx);
-       if (!evsel)
+       if (!evsel) {
+               perf_cpu_map__put(cpus);
                return NULL;
+       }
 
        (*idx)++;
        evsel->core.cpus = cpus;