diff options
author | Riccardo Mancini <rickyman7@gmail.com> | 2021-07-15 18:07:19 +0200 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2021-07-28 11:13:47 +0200 |
commit | 2c1d156b94636f8b6d00c95e39616efa6a6b894d (patch) | |
tree | 2bcb265e354e43c6b895be6f7fb751cf8dfad743 /tools | |
parent | 6cf3e71c229a729f4791341e14d6d7d910ff6ae0 (diff) | |
download | linux-stable-2c1d156b94636f8b6d00c95e39616efa6a6b894d.tar.gz linux-stable-2c1d156b94636f8b6d00c95e39616efa6a6b894d.tar.bz2 linux-stable-2c1d156b94636f8b6d00c95e39616efa6a6b894d.zip |
perf lzma: Close lzma stream on exit
[ Upstream commit f8cbb0f926ae1e1fb5f9e51614e5437560ed4039 ]
ASan reports memory leaks when running:
# perf test "88: Check open filename arg using perf trace + vfs_getname"
One of these is caused by the lzma stream never being closed inside
lzma_decompress_to_file().
This patch adds the missing lzma_end().
Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
Fixes: 80a32e5b498a7547 ("perf tools: Add lzma decompression support for kernel module")
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/aaf50bdce7afe996cfc06e1bbb36e4a2a9b9db93.1626343282.git.rickyman7@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/util/lzma.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/tools/perf/util/lzma.c b/tools/perf/util/lzma.c index b1dd29a9d915..6c844110fc25 100644 --- a/tools/perf/util/lzma.c +++ b/tools/perf/util/lzma.c @@ -68,7 +68,7 @@ int lzma_decompress_to_file(const char *input, int output_fd) if (ferror(infile)) { pr_err("lzma: read error: %s\n", strerror(errno)); - goto err_fclose; + goto err_lzma_end; } if (feof(infile)) @@ -82,7 +82,7 @@ int lzma_decompress_to_file(const char *input, int output_fd) if (writen(output_fd, buf_out, write_size) != write_size) { pr_err("lzma: write error: %s\n", strerror(errno)); - goto err_fclose; + goto err_lzma_end; } strm.next_out = buf_out; @@ -94,11 +94,13 @@ int lzma_decompress_to_file(const char *input, int output_fd) break; pr_err("lzma: failed %s\n", lzma_strerror(ret)); - goto err_fclose; + goto err_lzma_end; } } err = 0; +err_lzma_end: + lzma_end(&strm); err_fclose: fclose(infile); return err; |