Skip to contentSkip to conversation

perf data: close all files in close_dir

PATCH Superseded Riccardo Mancini 2 participants 2 messages Jun 21, 2021 – Jun 22, 2021 perf events

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 perf data: close all files in close_dir

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.

---
 tools/perf/util/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/data.c +1 -1
index 8fca4779ae6a..70b91ce35178 100644
@@ -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);
 	}
Signature · 1 line
2.23.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 6 lines · Riccardo Mancini

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.

Thanks,
Namhyung

Quoted 20 lines
---
 tools/perf/util/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/data.c +1 -2
index 8fca4779ae6a..70b91ce35178 100644
@@ -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);
        }
--

2.23.0