]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.14/perf-build-id-fix-memory-leak-in-print_sdt_events.patch
autosel patches for 4.14
[thirdparty/kernel/stable-queue.git] / queue-4.14 / perf-build-id-fix-memory-leak-in-print_sdt_events.patch
1 From 0f16bb520f67a277778db08ac1cba6f7ac6ff792 Mon Sep 17 00:00:00 2001
2 From: Changbin Du <changbin.du@gmail.com>
3 Date: Sat, 16 Mar 2019 16:05:46 +0800
4 Subject: perf build-id: Fix memory leak in print_sdt_events()
5
6 [ Upstream commit 8bde8516893da5a5fdf06121f74d11b52ab92df5 ]
7
8 Detected with gcc's ASan:
9
10 Direct leak of 4356 byte(s) in 120 object(s) allocated from:
11 #0 0x7ff1a2b5a070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
12 #1 0x55719aef4814 in build_id_cache__origname util/build-id.c:215
13 #2 0x55719af649b6 in print_sdt_events util/parse-events.c:2339
14 #3 0x55719af66272 in print_events util/parse-events.c:2542
15 #4 0x55719ad1ecaa in cmd_list /home/changbin/work/linux/tools/perf/builtin-list.c:58
16 #5 0x55719aec745d in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
17 #6 0x55719aec7d1a in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
18 #7 0x55719aec8184 in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
19 #8 0x55719aeca41a in main /home/changbin/work/linux/tools/perf/perf.c:520
20 #9 0x7ff1a07ae09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
21
22 Signed-off-by: Changbin Du <changbin.du@gmail.com>
23 Reviewed-by: Jiri Olsa <jolsa@kernel.org>
24 Cc: Alexei Starovoitov <ast@kernel.org>
25 Cc: Daniel Borkmann <daniel@iogearbox.net>
26 Cc: Masami Hiramatsu <masami.hiramatsu.pt@hitachi.com>
27 Cc: Namhyung Kim <namhyung@kernel.org>
28 Cc: Peter Zijlstra <peterz@infradead.org>
29 Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
30 Fixes: 40218daea1db ("perf list: Show SDT and pre-cached events")
31 Link: http://lkml.kernel.org/r/20190316080556.3075-7-changbin.du@gmail.com
32 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
33 Signed-off-by: Sasha Levin <sashal@kernel.org>
34 ---
35 tools/perf/util/build-id.c | 1 +
36 tools/perf/util/parse-events.c | 1 +
37 2 files changed, 2 insertions(+)
38
39 diff --git a/tools/perf/util/build-id.c b/tools/perf/util/build-id.c
40 index 7f8553630c4d..69910deab6e0 100644
41 --- a/tools/perf/util/build-id.c
42 +++ b/tools/perf/util/build-id.c
43 @@ -185,6 +185,7 @@ char *build_id_cache__linkname(const char *sbuild_id, char *bf, size_t size)
44 return bf;
45 }
46
47 +/* The caller is responsible to free the returned buffer. */
48 char *build_id_cache__origname(const char *sbuild_id)
49 {
50 char *linkname;
51 diff --git a/tools/perf/util/parse-events.c b/tools/perf/util/parse-events.c
52 index ec3517326a68..29e2bb304168 100644
53 --- a/tools/perf/util/parse-events.c
54 +++ b/tools/perf/util/parse-events.c
55 @@ -2180,6 +2180,7 @@ void print_sdt_events(const char *subsys_glob, const char *event_glob,
56 printf(" %-50s [%s]\n", buf, "SDT event");
57 free(buf);
58 }
59 + free(path);
60 } else
61 printf(" %-50s [%s]\n", nd->s, "SDT event");
62 if (nd2) {
63 --
64 2.19.1
65