Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f9d0c355 authored by Riccardo Mancini's avatar Riccardo Mancini Committed by Greg Kroah-Hartman
Browse files

perf inject: Close inject.output on exit



commit 02e6246f5364d5260a6ea6f92ab6f409058b162f 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: default avatarRiccardo Mancini <rickyman7@gmail.com>
Fixes: 6ef81c55 ("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: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent a9c103fa
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -836,8 +836,10 @@ int cmd_inject(int argc, const char **argv)

	data.path = inject.input_name;
	inject.session = perf_session__new(&data, inject.output.is_pipe, &inject.tool);
	if (IS_ERR(inject.session))
		return PTR_ERR(inject.session);
	if (IS_ERR(inject.session)) {
		ret = PTR_ERR(inject.session);
		goto out_close_output;
	}

	if (zstd_init(&(inject.session->zstd_data), 0) < 0)
		pr_warning("Decompression initialization failed.\n");
@@ -874,5 +876,7 @@ int cmd_inject(int argc, const char **argv)
out_delete:
	zstd_fini(&(inject.session->zstd_data));
	perf_session__delete(inject.session);
out_close_output:
	perf_data__close(&inject.output);
	return ret;
}