From: Miaoqian Lin Date: Thu, 29 Dec 2022 09:09:00 +0000 (+0400) Subject: perf tools: Fix resources leak in perf_data__open_dir() X-Git-Tag: v5.15.92~486 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;ds=sidebyside;h=a8f7fd322f566a9f2f05bc138c4dfc2ae1fe5e74;hp=a1e1521b463968b4eca7163f61fb6cc54d008061;p=platform%2Fkernel%2Flinux-rpi.git perf tools: Fix resources leak in perf_data__open_dir() [ Upstream commit 0a6564ebd953c4590663c9a3c99a3ea9920ade6f ] In perf_data__open_dir(), opendir() opens the directory stream. Add missing closedir() to release it after use. Fixes: eb6176709b235b96 ("perf data: Add perf_data__open_dir_data function") Reviewed-by: Adrian Hunter Signed-off-by: Miaoqian Lin Cc: Alexander Shishkin Cc: Alexey Bayduraev Cc: Ingo Molnar Cc: Jiri Olsa Cc: Mark Rutland Cc: Namhyung Kim Cc: Peter Zijlstra Link: https://lore.kernel.org/r/20221229090903.1402395-1-linmq006@gmail.com Signed-off-by: Arnaldo Carvalho de Melo Signed-off-by: Sasha Levin --- diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c index 15a4547..090a76b 100644 --- a/tools/perf/util/data.c +++ b/tools/perf/util/data.c @@ -127,6 +127,7 @@ int perf_data__open_dir(struct perf_data *data) file->size = st.st_size; } + closedir(dir); if (!files) return -EINVAL; @@ -135,6 +136,7 @@ int perf_data__open_dir(struct perf_data *data) return 0; out_err: + closedir(dir); close_dir(files, nr); return ret; }