selftests/bpf: Free the allocated resources after test case succeeds
authorHou Tao <houtao1@huawei.com>
Wed, 21 Sep 2022 07:00:35 +0000 (15:00 +0800)
committerMartin KaFai Lau <martin.lau@kernel.org>
Thu, 22 Sep 2022 23:41:27 +0000 (16:41 -0700)
commit103d002fb7d548fb1187e350f2b73788558128b9
treec54832297ee526b06e635e3b6fb1345d83913689
parentf5eb23b91c41a7ffc7ca7fe14f3c512360f02937
selftests/bpf: Free the allocated resources after test case succeeds

Free the created fd or allocated bpf_object after test case succeeds,
else there will be resource leaks.

Spotted by using address sanitizer and checking the content of
/proc/$pid/fd directory.

Signed-off-by: Hou Tao <houtao1@huawei.com>
Link: https://lore.kernel.org/r/20220921070035.2016413-3-houtao@huaweicloud.com
Signed-off-by: Martin KaFai Lau <martin.lau@kernel.org>
tools/testing/selftests/bpf/map_tests/array_map_batch_ops.c
tools/testing/selftests/bpf/map_tests/htab_map_batch_ops.c
tools/testing/selftests/bpf/map_tests/lpm_trie_map_batch_ops.c
tools/testing/selftests/bpf/test_maps.c