]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.14/perf-tests-fix-memory-leak-by-expr__find_other-in-te.patch
autosel patches for 4.14
[thirdparty/kernel/stable-queue.git] / queue-4.14 / perf-tests-fix-memory-leak-by-expr__find_other-in-te.patch
1 From 52637d46583ab6a7b98467b7e642b8bc89252728 Mon Sep 17 00:00:00 2001
2 From: Changbin Du <changbin.du@gmail.com>
3 Date: Sat, 16 Mar 2019 16:05:55 +0800
4 Subject: perf tests: Fix memory leak by expr__find_other() in test__expr()
5
6 [ Upstream commit f97a8991d3b998e518f56794d879f645964de649 ]
7
8 =================================================================
9 ==7506==ERROR: LeakSanitizer: detected memory leaks
10
11 Direct leak of 13 byte(s) in 3 object(s) allocated from:
12 #0 0x7f03339d6070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070)
13 #1 0x5625e53aaef0 in expr__find_other util/expr.y:221
14 #2 0x5625e51bcd3f in test__expr tests/expr.c:52
15 #3 0x5625e51528e6 in run_test tests/builtin-test.c:358
16 #4 0x5625e5152baf in test_and_print tests/builtin-test.c:388
17 #5 0x5625e51543fe in __cmd_test tests/builtin-test.c:583
18 #6 0x5625e515572f in cmd_test tests/builtin-test.c:722
19 #7 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302
20 #8 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354
21 #9 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398
22 #10 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520
23 #11 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a)
24
25 Signed-off-by: Changbin Du <changbin.du@gmail.com>
26 Cc: Alexei Starovoitov <ast@kernel.org>
27 Cc: Andi Kleen <ak@linux.intel.com>
28 Cc: Daniel Borkmann <daniel@iogearbox.net>
29 Cc: Jiri Olsa <jolsa@kernel.org>
30 Cc: Namhyung Kim <namhyung@kernel.org>
31 Cc: Peter Zijlstra <peterz@infradead.org>
32 Cc: Steven Rostedt (VMware) <rostedt@goodmis.org>
33 Fixes: 075167363f8b ("perf tools: Add a simple expression parser for JSON")
34 Link: http://lkml.kernel.org/r/20190316080556.3075-16-changbin.du@gmail.com
35 Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
36 Signed-off-by: Sasha Levin <sashal@kernel.org>
37 ---
38 tools/perf/tests/expr.c | 5 ++++-
39 1 file changed, 4 insertions(+), 1 deletion(-)
40
41 diff --git a/tools/perf/tests/expr.c b/tools/perf/tests/expr.c
42 index 01f0706995a9..9acc1e80b936 100644
43 --- a/tools/perf/tests/expr.c
44 +++ b/tools/perf/tests/expr.c
45 @@ -19,7 +19,7 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)
46 const char *p;
47 const char **other;
48 double val;
49 - int ret;
50 + int i, ret;
51 struct parse_ctx ctx;
52 int num_other;
53
54 @@ -56,6 +56,9 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)
55 TEST_ASSERT_VAL("find other", !strcmp(other[1], "BAZ"));
56 TEST_ASSERT_VAL("find other", !strcmp(other[2], "BOZO"));
57 TEST_ASSERT_VAL("find other", other[3] == NULL);
58 +
59 + for (i = 0; i < num_other; i++)
60 + free((void *)other[i]);
61 free((void *)other);
62
63 return 0;
64 --
65 2.19.1
66