Skip to content

Commit

Permalink
perf data: Close all files in close_dir()
Browse files Browse the repository at this point in the history
When using 'perf report' in directory mode, the first file is not closed
on exit, causing a memory leak.

The problem is caused by the iterating variable never reaching 0.

Fixes: 1455206 ("perf data: Add perf_data__(create_dir|close_dir) functions")
Signed-off-by: Riccardo Mancini <[email protected]>
Acked-by: Namhyung Kim <[email protected]>
Cc: Alexander Shishkin <[email protected]>
Cc: Ian Rogers <[email protected]>
Cc: Jiri Olsa <[email protected]>
Cc: Mark Rutland <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Zhen Lei <[email protected]>
Link: http://lore.kernel.org/lkml/[email protected]
Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
  • Loading branch information
Manciukic authored and acmel committed Jul 18, 2021
1 parent e0fa7ab commit d4b3eed
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/perf/util/data.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

static void close_dir(struct perf_data_file *files, int nr)
{
while (--nr >= 1) {
while (--nr >= 0) {
close(files[nr].fd);
zfree(&files[nr].path);
}
Expand Down

0 comments on commit d4b3eed

Please sign in to comment.