]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.170/perf-tests-fix-a-memory-leak-of-cpu_map-object-in-th.patch
Linux 4.9.170
[thirdparty/kernel/stable-queue.git] / releases / 4.9.170 / perf-tests-fix-a-memory-leak-of-cpu_map-object-in-th.patch
CommitLineData
5ddacef6
SLM
1From 7353318018fae6fee3a692bbdc45daec6663acb5 Mon Sep 17 00:00:00 2001
2From: Changbin Du <changbin.du@gmail.com>
3Date: Sat, 16 Mar 2019 16:05:54 +0800
4Subject: perf tests: Fix a memory leak of cpu_map object in the
5 openat_syscall_event_on_all_cpus test
6
7[ Upstream commit 93faa52e8371f0291ee1ff4994edae2b336b6233 ]
8
9 =================================================================
10 ==7497==ERROR: LeakSanitizer: detected memory leaks
11
12 Direct leak of 40 byte(s) in 1 object(s) allocated from:
13 #0 0x7f0333a88f30 in __interceptor_malloc (/usr/lib/x86_64-linux-gnu/libasan.so.5+0xedf30)
14 #1 0x5625e5326213 in cpu_map__trim_new util/cpumap.c:45
15 #2 0x5625e5326703 in cpu_map__read util/cpumap.c:103
16 #3 0x5625e53267ef in cpu_map__read_all_cpu_map util/cpumap.c:120
17 #4 0x5625e5326915 in cpu_map__new util/cpumap.c:135
18 #5 0x5625e517b355 in test__openat_syscall_event_on_all_cpus tests/openat-syscall-all-cpus.c:36
19 #6 0x5625e51528e6 in run_test tests/builtin-test.c:358
20 #7 0x5625e5152baf in test_and_print tests/builtin-test.c:388
21 #8 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
22 #9 0x5625e515572f in cmd_test tests/builtin-test.c:722
23 #10 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
24 #11 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
25 #12 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
26 #13 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
27 #14 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
28
29Signed-off-by: Changbin Du <changbin.du@gmail.com>
30Reviewed-by: Jiri Olsa <jolsa@kernel.org>
31Cc: Alexei Starovoitov <ast@kernel.org>
32Cc: Daniel Borkmann <daniel@iogearbox.net>
33Cc: Namhyung Kim <namhyung@kernel.org>
34Cc: Peter Zijlstra <peterz@infradead.org>
35Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
36Fixes: f30a79b012e5 ("perf tools: Add reference counting for cpu_map object")
37Link: http://lkml.kernel.org/r/20190316080556.3075-15-changbin.du@gmail.com
38Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
39Signed-off-by: Sasha Levin <sashal@kernel.org>
40---
41 tools/perf/tests/openat-syscall-all-cpus.c | 4 +++-
42 1 file changed, 3 insertions(+), 1 deletion(-)
43
44diff --git a/tools/perf/tests/openat-syscall-all-cpus.c b/tools/perf/tests/openat-syscall-all-cpus.c
45index c8d9592eb142..75d504e9eeaf 100644
46--- a/tools/perf/tests/openat-syscall-all-cpus.c
47+++ b/tools/perf/tests/openat-syscall-all-cpus.c
48@@ -38,7 +38,7 @@ int test__openat_syscall_event_on_all_cpus(int subtest __maybe_unused)
49 if (IS_ERR(evsel)) {
50 tracing_path__strerror_open_tp(errno, errbuf, sizeof(errbuf), "syscalls", "sys_enter_openat");
51 pr_debug("%s\n", errbuf);
52- goto out_thread_map_delete;
53+ goto out_cpu_map_delete;
54 }
55
56 if (perf_evsel__open(evsel, cpus, threads) < 0) {
57@@ -112,6 +112,8 @@ int test__openat_syscall_event_on_all_cpus(int subtest __maybe_unused)
58 perf_evsel__close_fd(evsel, 1, threads->nr);
59 out_evsel_delete:
60 perf_evsel__delete(evsel);
61+out_cpu_map_delete:
62+ cpu_map__put(cpus);
63 out_thread_map_delete:
64 thread_map__put(threads);
65 return err;
66--
672.19.1
68