linux-perf-users.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] perf tools: Fix resources leak in perf_data__open_dir
@ 2022-12-29  9:09 Miaoqian Lin
  2022-12-29 11:27 ` Adrian Hunter
  0 siblings, 1 reply; 3+ messages in thread
From: Miaoqian Lin @ 2022-12-29  9:09 UTC (permalink / raw)
  To: Peter Zijlstra, Ingo Molnar, Arnaldo Carvalho de Melo,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, Namhyung Kim,
	Adrian Hunter, Alexey Bayduraev, Miaoqian Lin, linux-perf-users,
	linux-kernel

In perf_data__open_dir(), opendir() opens the directory stream.
Add missing closedir() to release it after use.

Fixes: eb6176709b23 ("perf data: Add perf_data__open_dir_data function")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 tools/perf/util/data.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index a7f68c309545..fc16299c915f 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -132,6 +132,7 @@ int perf_data__open_dir(struct perf_data *data)
 		file->size = st.st_size;
 	}
 
+	closedir(dir);
 	if (!files)
 		return -EINVAL;
 
@@ -140,6 +141,7 @@ int perf_data__open_dir(struct perf_data *data)
 	return 0;
 
 out_err:
+	closedir(dir);
 	close_dir(files, nr);
 	return ret;
 }
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-01-02 14:46 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-29  9:09 [PATCH] perf tools: Fix resources leak in perf_data__open_dir Miaoqian Lin
2022-12-29 11:27 ` Adrian Hunter
2023-01-02 14:46   ` Arnaldo Carvalho de Melo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).