summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorRiccardo Mancini <rickyman7@gmail.com>2021-07-16 16:11:20 +0200
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2021-07-28 13:30:54 +0200
commit52cff6123aa0f8f6f85d4169a0a33a31a84d6fa5 (patch)
treebd1a510beae8b6ef7a2829afac2e0111f300d211 /tools
parent0f63857d109960557c8f80ca43de67a137e7d36b (diff)
perf data: Close all files in close_dir()
[ Upstream commit d4b3eedce151e63932ce4a00f1d0baa340a8b907 ] 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: 145520631130bd64 ("perf data: Add perf_data__(create_dir|close_dir) functions") Signed-off-by: Riccardo Mancini <rickyman7@gmail.com> Acked-by: Namhyung Kim <namhyung@kernel.org> Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com> Cc: Ian Rogers <irogers@google.com> Cc: Jiri Olsa <jolsa@redhat.com> Cc: Mark Rutland <mark.rutland@arm.com> Cc: Peter Zijlstra <peterz@infradead.org> Cc: Zhen Lei <thunder.leizhen@huawei.com> Link: http://lore.kernel.org/lkml/20210716141122.858082-1-rickyman7@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/perf/util/data.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tools/perf/util/data.c b/tools/perf/util/data.c
index 7534455ffc6a..a3f912615690 100644
--- a/tools/perf/util/data.c
+++ b/tools/perf/util/data.c
@@ -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);
}