Skip to content

Commit 0a6564e

Browse files
Yuuoniyacmel
authored andcommitted
perf tools: Fix resources leak in perf_data__open_dir()
In perf_data__open_dir(), opendir() opens the directory stream. Add missing closedir() to release it after use. Fixes: eb61767 ("perf data: Add perf_data__open_dir_data function") Reviewed-by: Adrian Hunter <[email protected]> Signed-off-by: Miaoqian Lin <[email protected]> Cc: Alexander Shishkin <[email protected]> Cc: Alexey Bayduraev <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Mark Rutland <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]>
1 parent 88603b6 commit 0a6564e

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/perf/util/data.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ int perf_data__open_dir(struct perf_data *data)
132132
file->size = st.st_size;
133133
}
134134

135+
closedir(dir);
135136
if (!files)
136137
return -EINVAL;
137138

@@ -140,6 +141,7 @@ int perf_data__open_dir(struct perf_data *data)
140141
return 0;
141142

142143
out_err:
144+
closedir(dir);
143145
close_dir(files, nr);
144146
return ret;
145147
}

0 commit comments

Comments
 (0)