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

perf script: Fix memory 'threads' and 'cpus' leaks on exit

ASan reports several memory leaks while running:

# perf test "82: Use vfs_getname probe to get syscall args filenames"

Two of these are caused by some refcounts not being decreased on
perf-script exit, namely script.threads and script.cpus.

This patch adds the missing __put calls in a new perf_script__exit
function, which is called at the end of cmd_script.

This patch concludes the fixes of all remaining memory leaks in perf
test "82: Use vfs_getname probe to get syscall args filenames".

Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
Fixes: cfc8874a48599249 ("perf script: Process cpu/threads maps")
Cc: Ian Rogers <irogers@google.com>
Cc: Jiri Olsa <jolsa@redhat.com>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: http://lore.kernel.org/lkml/5ee73b19791c6fa9d24c4d57f4ac1a23609400d7.1626343282.git.rickyman7@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Riccardo Mancini and committed by
Arnaldo Carvalho de Melo
faf3ac30 1b1f57cf

+7
+7
tools/perf/builtin-script.c
··· 2601 2601 } 2602 2602 } 2603 2603 2604 + static void perf_script__exit(struct perf_script *script) 2605 + { 2606 + perf_thread_map__put(script->threads); 2607 + perf_cpu_map__put(script->cpus); 2608 + } 2609 + 2604 2610 static int __cmd_script(struct perf_script *script) 2605 2611 { 2606 2612 int ret; ··· 4152 4146 zstd_fini(&(session->zstd_data)); 4153 4147 evlist__free_stats(session->evlist); 4154 4148 perf_session__delete(session); 4149 + perf_script__exit(&script); 4155 4150 4156 4151 if (script_started) 4157 4152 cleanup_scripting();