Skip to content

Commit 4c66a27

Browse files
changbindugregkh
authored andcommitted
perf tests: Fix memory leak by expr__find_other() in test__expr()
[ Upstream commit f97a899 ] ================================================================= ==7506==ERROR: LeakSanitizer: detected memory leaks Direct leak of 13 byte(s) in 3 object(s) allocated from: #0 0x7f03339d6070 in __interceptor_strdup (/usr/lib/x86_64-linux-gnu/libasan.so.5+0x3b070) #1 0x5625e53aaef0 in expr__find_other util/expr.y:221 raspberrypi#2 0x5625e51bcd3f in test__expr tests/expr.c:52 raspberrypi#3 0x5625e51528e6 in run_test tests/builtin-test.c:358 raspberrypi#4 0x5625e5152baf in test_and_print tests/builtin-test.c:388 raspberrypi#5 0x5625e51543fe in __cmd_test tests/builtin-test.c:583 raspberrypi#6 0x5625e515572f in cmd_test tests/builtin-test.c:722 raspberrypi#7 0x5625e51c3fb8 in run_builtin /home/changbin/work/linux/tools/perf/perf.c:302 raspberrypi#8 0x5625e51c44f7 in handle_internal_command /home/changbin/work/linux/tools/perf/perf.c:354 raspberrypi#9 0x5625e51c48fb in run_argv /home/changbin/work/linux/tools/perf/perf.c:398 raspberrypi#10 0x5625e51c5069 in main /home/changbin/work/linux/tools/perf/perf.c:520 raspberrypi#11 0x7f033214d09a in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x2409a) Signed-off-by: Changbin Du <[email protected]> Cc: Alexei Starovoitov <[email protected]> Cc: Andi Kleen <[email protected]> Cc: Daniel Borkmann <[email protected]> Cc: Jiri Olsa <[email protected]> Cc: Namhyung Kim <[email protected]> Cc: Peter Zijlstra <[email protected]> Cc: Steven Rostedt (VMware) <[email protected]> Fixes: 0751673 ("perf tools: Add a simple expression parser for JSON") Link: http://lkml.kernel.org/r/[email protected] Signed-off-by: Arnaldo Carvalho de Melo <[email protected]> Signed-off-by: Sasha Levin <[email protected]>
1 parent a0898f5 commit 4c66a27

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

tools/perf/tests/expr.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)
1919
const char *p;
2020
const char **other;
2121
double val;
22-
int ret;
22+
int i, ret;
2323
struct parse_ctx ctx;
2424
int num_other;
2525

@@ -56,6 +56,9 @@ int test__expr(struct test *t __maybe_unused, int subtest __maybe_unused)
5656
TEST_ASSERT_VAL("find other", !strcmp(other[1], "BAZ"));
5757
TEST_ASSERT_VAL("find other", !strcmp(other[2], "BOZO"));
5858
TEST_ASSERT_VAL("find other", other[3] == NULL);
59+
60+
for (i = 0; i < num_other; i++)
61+
free((void *)other[i]);
5962
free((void *)other);
6063

6164
return 0;

0 commit comments

Comments
 (0)