提交 bfd1b83d 编写于 作者: N Namhyung Kim 提交者: Arnaldo Carvalho de Melo

perf evlist: Fix cpu/thread map leak

Asan reported leak of cpu and thread maps as they have one more refcount
than released.  I found that after setting evlist maps it should release
it's refcount.

It seems to be broken from the beginning so I chose the original commit
as the culprit.  But not sure how it's applied to stable trees since
there are many changes in the code after that.

Fixes: 7e2ed097 ("perf evlist: Store pointer to the cpu and thread maps")
Fixes: 4112eb18 ("perf evlist: Default to syswide target when no thread/cpu maps set")
Signed-off-by: NNamhyung Kim <namhyung@kernel.org>
Acked-by: NJiri Olsa <jolsa@redhat.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Andi Kleen <ak@linux.intel.com>
Cc: Ian Rogers <irogers@google.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/20200915031819.386559-4-namhyung@kernel.orgSigned-off-by: NArnaldo Carvalho de Melo <acme@redhat.com>
上级 b033ab11
......@@ -946,6 +946,10 @@ int perf_evlist__create_maps(struct evlist *evlist, struct target *target)
perf_evlist__set_maps(&evlist->core, cpus, threads);
/* as evlist now has references, put count here */
perf_cpu_map__put(cpus);
perf_thread_map__put(threads);
return 0;
out_delete_threads:
......@@ -1273,11 +1277,12 @@ static int perf_evlist__create_syswide_maps(struct evlist *evlist)
goto out_put;
perf_evlist__set_maps(&evlist->core, cpus, threads);
out:
return err;
perf_thread_map__put(threads);
out_put:
perf_cpu_map__put(cpus);
goto out;
out:
return err;
}
int evlist__open(struct evlist *evlist)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册