Skip to contentSkip to conversation

perf data: close all files in close_dir

PATCH RESEND Applied Riccardo Mancini 2 participants 2 messages Jul 16, 2021 perf events

lore
Share & tools
lore
#0 lore raw

PATCH RESEND 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.

Cc Jiri Olsa <[email protected]>
Fixes 145520631130bd64 ("perf data: Add perf_data__(create_dir|close_dir) functions")

---
Hi Arnaldo,

I think this patch might have gone lost in the mailbox, submerged by other mails.
I'll take advantage of the resend to add the missing 'Fixes:' tag.

I didn't flag this as v2 since it contains no logical change, let me know if doing so would've been better.

Changes from first send:
- collected ack from Namhyung
- added Fixes: tag

Original: https://lkml.kernel.org/lkml/[email protected]/

Thanks,
Riccardo

---
 tools/perf/util/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/data.c +1 -1
index 8fca4779ae6a8e90..70b91ce35178c5f9 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 Applied
#1 lore raw

Em Fri, Jul 16, 2021 at 04:11:20PM +0200, Riccardo Mancini escreveu:

Quoted 3 lines

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, applied.

- Arnaldo

Quoted 42 lines
Cc Jiri Olsa <[email protected]>
Fixes 145520631130bd64 ("perf data: Add perf_data__(create_dir|close_dir) functions")

---
Hi Arnaldo,

I think this patch might have gone lost in the mailbox, submerged by other mails.
I'll take advantage of the resend to add the missing 'Fixes:' tag.

I didn't flag this as v2 since it contains no logical change, let me know if doing so would've been better.

Changes from first send:
- collected ack from Namhyung
- added Fixes: tag

Original: https://lkml.kernel.org/lkml/[email protected]/

Thanks,
Riccardo

---
 tools/perf/util/data.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/perf/util/data.c +1 -1
index 8fca4779ae6a8e90..70b91ce35178c5f9 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
Signature · 1 line
- Arnaldo