From: Ian Rogers Date: Thu, 19 Mar 2020 02:31:01 +0000 (-0700) Subject: libperf evlist: Fix a refcount leak X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=4599d292128d89e4cf866a0ea9a9b047a2de8418;p=linux.git libperf evlist: Fix a refcount leak Memory leaks found by applying LLVM's libfuzzer on the tools/perf parse_events function. Signed-off-by: Ian Rogers Cc: Adrian Hunter Cc: Alexander Shishkin Cc: Andi Kleen Cc: Jiri Olsa Cc: Leo Yan Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Cc: Stephane Eranian Cc: clang-built-linux@googlegroups.com Link: http://lore.kernel.org/lkml/20200319023101.82458-2-irogers@google.com [ Did a minor adjustment due to some other previous patch having already set evlist->all_cpus to NULL at perf_evlist__exit() ] Signed-off-by: Arnaldo Carvalho de Melo --- diff --git a/tools/lib/perf/evlist.c b/tools/lib/perf/evlist.c index c481b62f2ce45..6a875a0f01bb0 100644 --- a/tools/lib/perf/evlist.c +++ b/tools/lib/perf/evlist.c @@ -123,6 +123,7 @@ static void perf_evlist__purge(struct perf_evlist *evlist) void perf_evlist__exit(struct perf_evlist *evlist) { perf_cpu_map__put(evlist->cpus); + perf_cpu_map__put(evlist->all_cpus); perf_thread_map__put(evlist->threads); evlist->cpus = NULL; evlist->all_cpus = NULL;