Skip to content

Commit f8cbb0f

Browse files
Manciukicacmel
authored andcommitted
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: Riccardo Mancini <[email protected]> Fixes: 80a32e5 ("perf tools: Add lzma decompression support for kernel module") Cc: Ian Rogers <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: http://lore.kernel.org/lkml/aaf50bdce7afe996cfc06e1bbb36e4a2a9b9db93.1626343282.git.rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent faf3ac3 commit f8cbb0f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

tools/perf/util/lzma.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ int lzma_decompress_to_file(const char *input, int output_fd)
6969

7070
if (ferror(infile)) {
7171
pr_err("lzma: read error: %s\n", strerror(errno));
72-
goto err_fclose;
72+
goto err_lzma_end;
7373
}
7474

7575
if (feof(infile))
@@ -83,7 +83,7 @@ int lzma_decompress_to_file(const char *input, int output_fd)
8383

8484
if (writen(output_fd, buf_out, write_size) != write_size) {
8585
pr_err("lzma: write error: %s\n", strerror(errno));
86-
goto err_fclose;
86+
goto err_lzma_end;
8787
}
8888

8989
strm.next_out = buf_out;
@@ -95,11 +95,13 @@ int lzma_decompress_to_file(const char *input, int output_fd)
9595
break;
9696

9797
pr_err("lzma: failed %s\n", lzma_strerror(ret));
98-
goto err_fclose;
98+
goto err_lzma_end;
9999
}
100100
}
101101

102102
err = 0;
103+
err_lzma_end:
104+
lzma_end(&strm);
103105
err_fclose:
104106
fclose(infile);
105107
return err;

0 commit comments

Comments
 (0)