ASan reports a memory leak when running the 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]>
---
tools/perf/builtin-inject.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
index ffd2b25039e36e1d..c88c61e7f8ccb6a7 100644
--- a/tools/perf/builtin-inject.c
+++ b/tools/perf/builtin-inject.c
@@ -993,8 +993,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");
@@ -1036,6 +1038,8 @@ 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);
free(inject.itrace_synth_opts.vm_tm_corr_args);
return ret;
}
--
2.31.1
Em Thu, Jul 15, 2021 at 06:07:15PM +0200, Riccardo Mancini escreveu:
> ASan reports a memory leak when running the 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.
Fixes: 6ef81c55a2b6584c ("perf session: Return error code for perf_session__new() function on failure")
Thanks, applied.
- Arnaldo
> Signed-off-by: Riccardo Mancini <[email protected]>
> ---
> tools/perf/builtin-inject.c | 8 ++++++--
> 1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/tools/perf/builtin-inject.c b/tools/perf/builtin-inject.c
> index ffd2b25039e36e1d..c88c61e7f8ccb6a7 100644
> --- a/tools/perf/builtin-inject.c
> +++ b/tools/perf/builtin-inject.c
> @@ -993,8 +993,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");
> @@ -1036,6 +1038,8 @@ 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);
> free(inject.itrace_synth_opts.vm_tm_corr_args);
> return ret;
> }
> --
> 2.31.1
>
--
- Arnaldo