]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-5.0/perf-config-fix-a-memory-leak-in-collect_config.patch
autosel patches for 5.0
[thirdparty/kernel/stable-queue.git] / queue-5.0 / perf-config-fix-a-memory-leak-in-collect_config.patch
1 From 8f66c21c284348b5b00c11b90b06f09489b887d5 Mon Sep 17 00:00:00 2001
2 From: Changbin Du <changbin.du@gmail.com>
3 Date: Sat, 16 Mar 2019 16:05:45 +0800
4 Subject: perf config: Fix a memory leak in collect_config()
5
6 [ Upstream commit 54569ba4b06d5baedae4614bde33a25a191473ba ]
7
8 Detected with gcc's ASan:
9
10 Direct leak of 66 byte(s) in 5 object(s) allocated from:
11 #0 0x7ff3b1f32070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
12 #1 0x560c8761034d in collect_config util/config.c:597
13 #2 0x560c8760d9cb in get_value util/config.c:169
14 #3 0x560c8760dfd7 in perf_parse_file util/config.c:285
15 #4 0x560c8760e0d2 in perf_config_from_file util/config.c:476
16 #5 0x560c876108fd in perf_config_set__init util/config.c:661
17 #6 0x560c87610c72 in perf_config_set__new util/config.c:709
18 #7 0x560c87610d2f in perf_config__init util/config.c:718
19 #8 0x560c87610e5d in perf_config util/config.c:730
20 #9 0x560c875ddea0 in main /home/changbin/work/linux/tools/perf/perf.c:442
21 #10 0x7ff3afb8609a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
22
23 Signed-off-by: Changbin Du <changbin.du@gmail.com>
24 Reviewed-by: Jiri Olsa <jolsa@kernel.org>
25 Cc: Alexei Starovoitov <ast@kernel.org>
26 Cc: Daniel Borkmann <daniel@iogearbox.net>
27 Cc: Namhyung Kim <namhyung@kernel.org>
28 Cc: Peter Zijlstra <peterz@infradead.org>
29 Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
30 Cc: Taeung Song <treeze.taeung@gmail.com>
31 Fixes: 20105ca1240c ("perf config: Introduce perf_config_set class")
32 Link: http://lkml.kernel.org/r/20190316080556.3075-6-changbin.du@gmail.com
33 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
34 Signed-off-by: Sasha Levin <sashal@kernel.org>
35 ---
36 tools/perf/util/config.c | 3 +--
37 1 file changed, 1 insertion(+), 2 deletions(-)
38
39 diff --git a/tools/perf/util/config.c b/tools/perf/util/config.c
40 index 1ea8f898f1a1..9ecdbd5986b3 100644
41 --- a/tools/perf/util/config.c
42 +++ b/tools/perf/util/config.c
43 @@ -632,11 +632,10 @@ static int collect_config(const char *var, const char *value,
44 }
45
46 ret = set_value(item, value);
47 - return ret;
48
49 out_free:
50 free(key);
51 - return -1;
52 + return ret;
53 }
54
55 int perf_config_set__collect(struct perf_config_set *set, const char *file_name,
56 --
57 2.19.1
58