]> git.baikalelectronics.ru Git - kernel.git/commitdiff
perf tools: Fix resources leak in perf_data__open_dir()
authorMiaoqian Lin <linmq006@gmail.com>
Thu, 29 Dec 2022 09:09:00 +0000 (13:09 +0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 18 Jan 2023 10:41:58 +0000 (11:41 +0100)
[ Upstream commit 0a6564ebd953c4590663c9a3c99a3ea9920ade6f ]

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

Fixes: 066bf0347c3af57d ("perf data: Add perf_data__open_dir_data function")
Reviewed-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
Cc: Alexey Bayduraev <alexey.v.bayduraev@linux.intel.com>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Jiri Olsa <jolsa@kernel.org>
Cc: Mark Rutland <mark.rutland@arm.com>
Cc: Namhyung Kim <namhyung@kernel.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Link: https://lore.kernel.org/r/20221229090903.1402395-1-linmq006@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
tools/perf/util/data.c

index 3c874f52f1a25d8ea865e689f588a410a1699562..4da900bdb2f18123e90048a69cf327145233fd81 100644 (file)
@@ -120,6 +120,7 @@ int perf_data__open_dir(struct perf_data *data)
                file->size = st.st_size;
        }
 
+       closedir(dir);
        if (!files)
                return -EINVAL;
 
@@ -128,6 +129,7 @@ int perf_data__open_dir(struct perf_data *data)
        return 0;
 
 out_err:
+       closedir(dir);
        close_dir(files, nr);
        return ret;
 }