Skip to content

Commit

Permalink
perf lzma: Close lzma stream on exit
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Manciukic authored and acmel committed Jul 15, 2021
1 parent faf3ac3 commit f8cbb0f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions tools/perf/util/lzma.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,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))
Expand All @@ -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) {
pr_err("lzma: write error: %s\n", strerror(errno));
goto err_fclose;
goto err_lzma_end;
}

strm.next_out = buf_out;
Expand All @@ -95,11 +95,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;
Expand Down

0 comments on commit f8cbb0f

Please sign in to comment.