Skip to contentSkip to conversation

perf bench: Fix memory leaks.

PATCH Applied Sohaib Mohamed 2 participants 2 messages Nov 10, 2021 – Nov 17, 2021 perf events

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 perf bench: Fix memory leaks.

ASan reports memory leaks while running:

$ perf bench sched all
Fixes e27454cc6352 ("perf bench: Add sched-messaging.c: Benchmark for

scheduler and IPC mechanisms based on hackbench")

---
 tools/perf/bench/sched-messaging.c | 4 ++++
 1 file changed, 4 insertions(+)
tools/perf/bench/sched-messaging.c +4 -0
index 488f6e6ba1a5..fa0ff4ce2b74 100644
@@ -223,6 +223,8 @@ static unsigned int group(pthread_t *pth,
 		snd_ctx->out_fds[i] = fds[1];
 		if (!thread_mode)
 			close(fds[0]);
+
+		free(ctx);
 	}
 
 	/* Now we have all the fds, fork the senders */
@@ -239,6 +241,8 @@ static unsigned int group(pthread_t *pth,
 		for (i = 0; i < num_fds; i++)
 			close(snd_ctx->out_fds[i]);
 
+	free(snd_ctx);
+
 	/* Return number of children to reap */
 	return num_fds * 2;
 }

--
2.25.1

maintainer Applied
#1 lore raw

Em Wed, Nov 10, 2021 at 04:20:11AM +0200, Sohaib Mohamed escreveu:

Quoted 5 lines

ASan reports memory leaks while running:

$ perf bench sched all
Fixes e27454cc6352 ("perf bench: Add sched-messaging.c: Benchmark for

scheduler and IPC mechanisms based on hackbench")

Thanks, applied.

- Arnaldo

Quoted 30 lines
---
 tools/perf/bench/sched-messaging.c | 4 ++++
 1 file changed, 4 insertions(+)
tools/perf/bench/sched-messaging.c +4 -1
index 488f6e6ba1a5..fa0ff4ce2b74 100644
@@ -223,6 +223,8 @@ static unsigned int group(pthread_t *pth,
 		snd_ctx->out_fds[i] = fds[1];
 		if (!thread_mode)
 			close(fds[0]);
+
+		free(ctx);
 	}
 
 	/* Now we have all the fds, fork the senders */
@@ -239,6 +241,8 @@ static unsigned int group(pthread_t *pth,
 		for (i = 0; i < num_fds; i++)
 			close(snd_ctx->out_fds[i]);
 
+	free(snd_ctx);
+
 	/* Return number of children to reap */
 	return num_fds * 2;
 }
--

2.25.1

Signature · 1 line
- Arnaldo