[PATCH 5.7 126/376] selftests/bpf: Fix bpf_link leak in ns_current_pid_tgid selftest
From: Greg Kroah-Hartman
Date: Fri Jun 19 2020 - 11:54:40 EST
From: Andrii Nakryiko <andriin@xxxxxx>
[ Upstream commit 8d30e80a049ad699264e4a12911e349f93c7279a ]
If condition is inverted, but it's also just not necessary.
Fixes: 1c1052e0140a ("tools/testing/selftests/bpf: Add self-tests for new helper bpf_get_ns_current_pid_tgid.")
Signed-off-by: Andrii Nakryiko <andriin@xxxxxx>
Signed-off-by: Alexei Starovoitov <ast@xxxxxxxxxx>
Cc: Carlos Neira <cneirabustos@xxxxxxxxx>
Link: https://lore.kernel.org/bpf/20200429012111.277390-11-andriin@xxxxxx
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c b/tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c
index 542240e16564..e74dc501b27f 100644
--- a/tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c
+++ b/tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c
@@ -80,9 +80,6 @@ void test_ns_current_pid_tgid(void)
"User pid/tgid %llu BPF pid/tgid %llu\n", id, bss.pid_tgid))
goto cleanup;
cleanup:
- if (!link) {
- bpf_link__destroy(link);
- link = NULL;
- }
+ bpf_link__destroy(link);
bpf_object__close(obj);
}
--
2.25.1