aboutsummaryrefslogtreecommitdiffstats
path: root/tools/testing/selftests/bpf/prog_tests/tracing_struct.c
diff options
context:
space:
mode:
authorXu Kuohai <[email protected]>2022-10-11 12:01:05 +0000
committerAndrii Nakryiko <[email protected]>2022-10-13 17:53:22 +0000
commit6e8280b958c5d7edc514cf347a800b23b7732b2b (patch)
treedd89061a3f008f63487277a0f3ed2710b2aae3ec /tools/testing/selftests/bpf/prog_tests/tracing_struct.c
parentlibbpf: Fix memory leak in parse_usdt_arg() (diff)
downloadkernel-6e8280b958c5d7edc514cf347a800b23b7732b2b.tar.gz
kernel-6e8280b958c5d7edc514cf347a800b23b7732b2b.zip
selftests/bpf: Fix memory leak caused by not destroying skeleton
Some test cases does not destroy skeleton object correctly, causing ASAN to report memory leak warning. Fix it. Fixes: 0ef6740e9777 ("selftests/bpf: Add tests for kptr_ref refcounting") Fixes: 1642a3945e22 ("selftests/bpf: Add struct argument tests with fentry/fexit programs.") Signed-off-by: Xu Kuohai <[email protected]> Signed-off-by: Andrii Nakryiko <[email protected]> Acked-by: Martin KaFai Lau <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/tracing_struct.c')
-rw-r--r--tools/testing/selftests/bpf/prog_tests/tracing_struct.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/tracing_struct.c b/tools/testing/selftests/bpf/prog_tests/tracing_struct.c
index d5022b91d1e4..48dc9472e160 100644
--- a/tools/testing/selftests/bpf/prog_tests/tracing_struct.c
+++ b/tools/testing/selftests/bpf/prog_tests/tracing_struct.c
@@ -15,7 +15,7 @@ static void test_fentry(void)
err = tracing_struct__attach(skel);
if (!ASSERT_OK(err, "tracing_struct__attach"))
- return;
+ goto destroy_skel;
ASSERT_OK(trigger_module_test_read(256), "trigger_read");
@@ -54,6 +54,7 @@ static void test_fentry(void)
ASSERT_EQ(skel->bss->t5_ret, 1, "t5 ret");
tracing_struct__detach(skel);
+destroy_skel:
tracing_struct__destroy(skel);
}