Commit 6e8280b9 authored by Xu Kuohai's avatar Xu Kuohai Committed by Andrii Nakryiko
Browse files

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: 0ef6740e ("selftests/bpf: Add tests for kptr_ref refcounting")
Fixes: 1642a394 ("selftests/bpf: Add struct argument tests with fentry/fexit programs.")
Signed-off-by: default avatarXu Kuohai <xukuohai@huawei.com>
Signed-off-by: default avatarAndrii Nakryiko <andrii@kernel.org>
Acked-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
Link: https://lore.kernel.org/bpf/20221011120108.782373-4-xukuohai@huaweicloud.com
parent 0dc9254e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -105,7 +105,7 @@ static void test_map_kptr_success(bool test_run)
	ASSERT_OK(opts.retval, "test_map_kptr_ref2 retval");

	if (test_run)
		return;
		goto exit;

	ret = bpf_map__update_elem(skel->maps.array_map,
				   &key, sizeof(key), buf, sizeof(buf), 0);
@@ -132,6 +132,7 @@ static void test_map_kptr_success(bool test_run)
	ret = bpf_map__delete_elem(skel->maps.lru_hash_map, &key, sizeof(key), 0);
	ASSERT_OK(ret, "lru_hash_map delete");

exit:
	map_kptr__destroy(skel);
}

+2 −1
Original line number Diff line number Diff line
@@ -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);
}