]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
selftests/bpf: Fix btf leak on new btf alloc failure in btf_distill test
authorPu Lehui <pulehui@huawei.com>
Wed, 15 Jan 2025 10:02:38 +0000 (10:02 +0000)
committerAndrii Nakryiko <andrii@kernel.org>
Thu, 16 Jan 2025 23:34:18 +0000 (15:34 -0800)
Fix btf leak on new btf alloc failure in btf_distill test.

Fixes: affdeb50616b ("selftests/bpf: Extend distilled BTF tests to cover BTF relocation")
Signed-off-by: Pu Lehui <pulehui@huawei.com>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20250115100241.4171581-1-pulehui@huaweicloud.com
tools/testing/selftests/bpf/prog_tests/btf_distill.c

index ca84726d5ac1b91ed340b47090ad27a50f7926f2..b72b966df77b90b2b6a5175aaa36d4cb5fab3c16 100644 (file)
@@ -385,7 +385,7 @@ static void test_distilled_base_missing_err(void)
                "[2] INT 'int' size=8 bits_offset=0 nr_bits=64 encoding=SIGNED");
        btf5 = btf__new_empty();
        if (!ASSERT_OK_PTR(btf5, "empty_reloc_btf"))
-               return;
+               goto cleanup;
        btf__add_int(btf5, "int", 4, BTF_INT_SIGNED);   /* [1] int */
        VALIDATE_RAW_BTF(
                btf5,
@@ -478,7 +478,7 @@ static void test_distilled_base_multi_err2(void)
                "[1] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED");
        btf5 = btf__new_empty();
        if (!ASSERT_OK_PTR(btf5, "empty_reloc_btf"))
-               return;
+               goto cleanup;
        btf__add_int(btf5, "int", 4, BTF_INT_SIGNED);   /* [1] int */
        btf__add_int(btf5, "int", 4, BTF_INT_SIGNED);   /* [2] int */
        VALIDATE_RAW_BTF(