Subject: [PATCH AUTOSEL 5.15 010/188] selftests/bpf: Fix bpf_object leak in skb_ctx selftest

From: Sasha Levin <[email-masked]>
Date: Mon, 17 Jan 2022 21:28:54 -0500

From: Andrii Nakryiko <[email-masked]>

[ Upstream commit 8c7a95520184b6677ca6075e12df9c208d57d088 ]

skb_ctx selftest didn't close bpf_object implicitly allocated by
bpf_prog_test_load() helper. Fix the problem by explicitly calling
bpf_object__close() at the end of the test.

Signed-off-by: Andrii Nakryiko <[email-masked]>
Signed-off-by: Alexei Starovoitov <[email-masked]>
Reviewed-by: Hengqi Chen <[email-masked]>
Link: https://lore.kernel.org/bpf/[email-masked]
Signed-off-by: Sasha Levin <[email-masked]>
---
 tools/testing/selftests/bpf/prog_tests/skb_ctx.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/bpf/prog_tests/skb_ctx.c b/tools/testing/selftests/bpf/prog_tests/skb_ctx.c
index fafeddaad6a99..23915be6172d6 100644
--- a/tools/testing/selftests/bpf/prog_tests/skb_ctx.c
+++ b/tools/testing/selftests/bpf/prog_tests/skb_ctx.c
@@ -105,4 +105,6 @@ void test_skb_ctx(void)
 		   "ctx_out_mark",
 		   "skb->mark == %u, expected %d\n",
 		   skb.mark, 10);
+
+	bpf_object__close(obj);
 }
-- 
2.34.1