File perf-bench-Fix-two-memory-leaks-detected-with-ASan.patch of Package perf
53
1
From: Sohaib Mohamed <sohaib.amhmd@gmail.com>
2
Date: Wed, 10 Nov 2021 04:20:11 +0200
3
Subject: perf bench: Fix two memory leaks detected with ASan
4
Git-commit: 92723ea0f11d92496687db8c9725248e9d1e5e1d
5
Patch-mainline: v5.16-rc2
6
References: git-fixes
7
8
ASan reports memory leaks while running:
9
10
$ perf bench sched all
11
12
Fixes: e27454cc6352c422 ("perf bench: Add sched-messaging.c: Benchmark for scheduler and IPC mechanisms based on hackbench")
13
Signed-off-by: Sohaib Mohamed <sohaib.amhmd@gmail.com>
14
Acked-by: Ian Rogers <irogers@google.com>
15
Cc: Alexander Shishkin <alexander.shishkin@linux.intel.com>
16
Cc: Hitoshi Mitake <h.mitake@gmail.com>
17
Cc: Jiri Olsa <jolsa@redhat.com>
18
Cc: Mark Rutland <mark.rutland@arm.com>
19
Cc: Namhyung Kim <namhyung@kernel.org>
20
Cc: Paul Russel <rusty@rustcorp.com.au>
21
Cc: Peter Zijlstra <peterz@infradead.org>
22
Cc: Pierre Gondois <pierre.gondois@arm.com>
23
Link: http://lore.kernel.org/lkml/20211110022012.16620-1-sohaib.amhmd@gmail.com
24
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
25
Signed-off-by: Tony Jones <tonyj@suse.de>
26
---
27
tools/perf/bench/sched-messaging.c | 4 ++++
28
1 file changed, 4 insertions(+)
29
30
diff --git a/tools/perf/bench/sched-messaging.c b/tools/perf/bench/sched-messaging.c
31
index 488f6e6ba1a5..fa0ff4ce2b74 100644
32
--- a/tools/perf/bench/sched-messaging.c
33
+++ b/tools/perf/bench/sched-messaging.c
34
35
snd_ctx->out_fds[i] = fds[1];
36
if (!thread_mode)
37
close(fds[0]);
38
+
39
+ free(ctx);
40
}
41
42
/* Now we have all the fds, fork the senders */
43
44
for (i = 0; i < num_fds; i++)
45
close(snd_ctx->out_fds[i]);
46
47
+ free(snd_ctx);
48
+
49
/* Return number of children to reap */
50
return num_fds * 2;
51
}
52
53