Skip to content

Commit 02e6246

Browse files
Manciukicacmel
authored andcommitted
perf inject: Close inject.output on exit
ASan reports a memory leak when running: # perf test "83: Zstd perf.data compression/decompression" which happens inside 'perf inject'. The bug is caused by inject.output never being closed. This patch adds the missing perf_data__close(). Signed-off-by: Riccardo Mancini <[email protected]> Fixes: 6ef81c5 ("perf session: Return error code for perf_session__new() function on failure") Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mamatha Inamdar <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lore.kernel.org/lkml/c06f682afa964687367cf6e92a64ceb49aec76a5.1626343282.git.rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent a37338a commit 02e6246

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

tools/perf/builtin-inject.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -993,8 +993,10 @@ int cmd_inject(int argc, const char **argv)
993993

994994
data.path = inject.input_name;
995995
inject.session = perf_session__new(&data, inject.output.is_pipe, &inject.tool);
996-
if (IS_ERR(inject.session))
997-
return PTR_ERR(inject.session);
996+
if (IS_ERR(inject.session)) {
997+
ret = PTR_ERR(inject.session);
998+
goto out_close_output;
999+
}
9981000

9991001
if (zstd_init(&(inject.session->zstd_data), 0) < 0)
10001002
pr_warning("Decompression initialization failed.\n");
@@ -1036,6 +1038,8 @@ int cmd_inject(int argc, const char **argv)
10361038
out_delete:
10371039
zstd_fini(&(inject.session->zstd_data));
10381040
perf_session__delete(inject.session);
1041+
out_close_output:
1042+
perf_data__close(&inject.output);
10391043
free(inject.itrace_synth_opts.vm_tm_corr_args);
10401044
return ret;
10411045
}

0 commit comments

Comments
 (0)