Skip to content

Commit 9bad2ea

Browse files
Manciukicgregkh
authored andcommitted
perf inject: Close inject.output on exit
commit 02e6246 upstream. 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 <rickyman7@gmail.com> Fixes: 6ef81c5 ("perf session: Return error code for perf_session__new() function on failure") Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mamatha Inamdar <mamatha4@linux.vnet.ibm.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/c06f682afa964687367cf6e92a64ceb49aec76a5.1626343282.git.rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 5cf3d39 commit 9bad2ea

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

‎tools/perf/builtin-inject.c‎

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

909909
data.path = inject.input_name;
910910
inject.session = perf_session__new(&data, inject.output.is_pipe, &inject.tool);
911-
if (IS_ERR(inject.session))
912-
return PTR_ERR(inject.session);
911+
if (IS_ERR(inject.session)) {
912+
ret = PTR_ERR(inject.session);
913+
goto out_close_output;
914+
}
913915

914916
if (zstd_init(&(inject.session->zstd_data), 0) < 0)
915917
pr_warning("Decompression initialization failed.\n");
@@ -951,5 +953,7 @@ int cmd_inject(int argc, const char **argv)
951953
out_delete:
952954
zstd_fini(&(inject.session->zstd_data));
953955
perf_session__delete(inject.session);
956+
out_close_output:
957+
perf_data__close(&inject.output);
954958
return ret;
955959
}

0 commit comments

Comments
 (0)