diff options
author | Hou Tao <houtao1@huawei.com> | 2022-09-21 10:00:35 +0300 |
---|---|---|
committer | Martin KaFai Lau <martin.lau@kernel.org> | 2022-09-23 02:41:27 +0300 |
commit | 103d002fb7d548fb1187e350f2b73788558128b9 (patch) | |
tree | c54832297ee526b06e635e3b6fb1345d83913689 /tools/testing/selftests/bpf/map_tests/htab_map_batch_ops.c | |
parent | f5eb23b91c41a7ffc7ca7fe14f3c512360f02937 (diff) | |
download | linux-103d002fb7d548fb1187e350f2b73788558128b9.tar.xz |
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>
Diffstat (limited to 'tools/testing/selftests/bpf/map_tests/htab_map_batch_ops.c')
-rw-r--r-- | tools/testing/selftests/bpf/map_tests/htab_map_batch_ops.c | 2 |
1 files changed, 2 insertions, 0 deletions
diff --git a/tools/testing/selftests/bpf/map_tests/htab_map_batch_ops.c b/tools/testing/selftests/bpf/map_tests/htab_map_batch_ops.c index f807d53fd8dd..1230ccf90128 100644 --- a/tools/testing/selftests/bpf/map_tests/htab_map_batch_ops.c +++ b/tools/testing/selftests/bpf/map_tests/htab_map_batch_ops.c @@ -3,6 +3,7 @@ #include <stdio.h> #include <errno.h> #include <string.h> +#include <unistd.h> #include <bpf/bpf.h> #include <bpf/libbpf.h> @@ -255,6 +256,7 @@ void __test_map_lookup_and_delete_batch(bool is_pcpu) free(visited); if (!is_pcpu) free(values); + close(map_fd); } void htab_map_batch_ops(void) |