Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf test code-reading: Avoid a leak of cpus and threads

The perf_evlist__set_maps does the necessary gets on the arguments
passed, so the reference count bumping isn't necessary and creates a
memory leak.

Signed-off-by: Ian Rogers <irogers@google.com>
Link: https://lore.kernel.org/r/20250624190326.2038704-3-irogers@google.com
Signed-off-by: Namhyung Kim <namhyung@kernel.org>

authored by

Ian Rogers and committed by
Namhyung Kim
7a8557fc 63a088e9

-7
-7
tools/perf/tests/code-reading.c
··· 749 749 pr_debug("perf_evlist__open() failed!\n%s\n", errbuf); 750 750 } 751 751 752 - /* 753 - * Both cpus and threads are now owned by evlist 754 - * and will be freed by following perf_evlist__set_maps 755 - * call. Getting reference to keep them alive. 756 - */ 757 - perf_cpu_map__get(cpus); 758 - perf_thread_map__get(threads); 759 752 perf_evlist__set_maps(&evlist->core, NULL, NULL); 760 753 evlist__delete(evlist); 761 754 evlist = NULL;