perf test code-reading: Avoid a leak of cpus and threads
authorIan Rogers <irogers@google.com>
Tue, 24 Jun 2025 19:03:22 +0000 (12:03 -0700)
committerNamhyung Kim <namhyung@kernel.org>
Thu, 3 Jul 2025 02:05:26 +0000 (19:05 -0700)
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>
tools/perf/tests/code-reading.c

index cf6edbe697b2517826129354834db8b5b8b53054..6efb6b4bbcce9752a311616107de8ab3a0b1bccc 100644 (file)
@@ -749,13 +749,6 @@ static int do_test_code_reading(bool try_kcore)
                                pr_debug("perf_evlist__open() failed!\n%s\n", errbuf);
                        }
 
-                       /*
-                        * Both cpus and threads are now owned by evlist
-                        * and will be freed by following perf_evlist__set_maps
-                        * call. Getting reference to keep them alive.
-                        */
-                       perf_cpu_map__get(cpus);
-                       perf_thread_map__get(threads);
                        perf_evlist__set_maps(&evlist->core, NULL, NULL);
                        evlist__delete(evlist);
                        evlist = NULL;