Skip to content

Commit bfd1b83

Browse files
namhyungacmel
authored andcommitted
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: 7e2ed09 ("perf evlist: Store pointer to the cpu and thread maps") Fixes: 4112eb1 ("perf evlist: Default to syswide target when no thread/cpu maps set") Signed-off-by: Namhyung Kim <[email protected]> Acked-by: Jiri Olsa <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Ian Rogers <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Stephane Eranian <[email protected]> Link: http://lore.kernel.org/lkml/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent b033ab1 commit bfd1b83

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

tools/perf/util/evlist.c

+8-3
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,10 @@ int perf_evlist__create_maps(struct evlist *evlist, struct target *target)
946946

947947
perf_evlist__set_maps(&evlist->core, cpus, threads);
948948

949+
/* as evlist now has references, put count here */
950+
perf_cpu_map__put(cpus);
951+
perf_thread_map__put(threads);
952+
949953
return 0;
950954

951955
out_delete_threads:
@@ -1273,11 +1277,12 @@ static int perf_evlist__create_syswide_maps(struct evlist *evlist)
12731277
goto out_put;
12741278

12751279
perf_evlist__set_maps(&evlist->core, cpus, threads);
1276-
out:
1277-
return err;
1280+
1281+
perf_thread_map__put(threads);
12781282
out_put:
12791283
perf_cpu_map__put(cpus);
1280-
goto out;
1284+
out:
1285+
return err;
12811286
}
12821287

12831288
int evlist__open(struct evlist *evlist)

0 commit comments

Comments
 (0)