]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
perf mem-events: Don't leak online CPU map
authorIan Rogers <irogers@google.com>
Sat, 22 Nov 2025 08:19:19 +0000 (00:19 -0800)
committerNamhyung Kim <namhyung@kernel.org>
Wed, 3 Dec 2025 19:07:46 +0000 (11:07 -0800)
Reference count checking found the online CPU map was being gotten but
not put. Add in the missing put.

Signed-off-by: Ian Rogers <irogers@google.com>
Reviewed-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
tools/perf/util/mem-events.c

index 80b3069427bc4bb5ffc3ab0856c01c76d9ba3ba6..0b49fce251fcc18417cb1037075b3e406a3e6481 100644 (file)
@@ -303,12 +303,15 @@ int perf_mem_events__record_args(const char **rec_argv, int *argv_nr, char **eve
        }
 
        if (cpu_map) {
-               if (!perf_cpu_map__equal(cpu_map, cpu_map__online())) {
+               struct perf_cpu_map *online = cpu_map__online();
+
+               if (!perf_cpu_map__equal(cpu_map, online)) {
                        char buf[200];
 
                        cpu_map__snprint(cpu_map, buf, sizeof(buf));
                        pr_warning("Memory events are enabled on a subset of CPUs: %s\n", buf);
                }
+               perf_cpu_map__put(online);
                perf_cpu_map__put(cpu_map);
        }