Commit f8cbb0f9 authored by Riccardo Mancini's avatar Riccardo Mancini Committed by Arnaldo Carvalho de Melo

perf lzma: Close lzma stream on exit

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: default avatarRiccardo Mancini <rickyman7@gmail.com>
Fixes: 80a32e5b ("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.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent faf3ac30
...@@ -69,7 +69,7 @@ int lzma_decompress_to_file(const char *input, int output_fd) ...@@ -69,7 +69,7 @@ int lzma_decompress_to_file(const char *input, int output_fd)
if (ferror(infile)) { if (ferror(infile)) {
pr_err("lzma: read error: %s\n", strerror(errno)); pr_err("lzma: read error: %s\n", strerror(errno));
goto err_fclose; goto err_lzma_end;
} }
if (feof(infile)) if (feof(infile))
...@@ -83,7 +83,7 @@ int lzma_decompress_to_file(const char *input, int output_fd) ...@@ -83,7 +83,7 @@ int lzma_decompress_to_file(const char *input, int output_fd)
if (writen(output_fd, buf_out, write_size) != write_size) { if (writen(output_fd, buf_out, write_size) != write_size) {
pr_err("lzma: write error: %s\n", strerror(errno)); pr_err("lzma: write error: %s\n", strerror(errno));
goto err_fclose; goto err_lzma_end;
} }
strm.next_out = buf_out; strm.next_out = buf_out;
...@@ -95,11 +95,13 @@ int lzma_decompress_to_file(const char *input, int output_fd) ...@@ -95,11 +95,13 @@ int lzma_decompress_to_file(const char *input, int output_fd)
break; break;
pr_err("lzma: failed %s\n", lzma_strerror(ret)); pr_err("lzma: failed %s\n", lzma_strerror(ret));
goto err_fclose; goto err_lzma_end;
} }
} }
err = 0; err = 0;
err_lzma_end:
lzma_end(&strm);
err_fclose: err_fclose:
fclose(infile); fclose(infile);
return err; return err;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment