selftests/bpf: Fix bpf_link leak in ns_current_pid_tgid selftest
authorAndrii Nakryiko <andriin@fb.com>
Wed, 29 Apr 2020 01:21:10 +0000 (18:21 -0700)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 29 Apr 2020 02:48:05 +0000 (19:48 -0700)
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@fb.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Cc: Carlos Neira <cneirabustos@gmail.com>
Link: https://lore.kernel.org/bpf/20200429012111.277390-11-andriin@fb.com
tools/testing/selftests/bpf/prog_tests/ns_current_pid_tgid.c

index 542240e16564412d6b928ecd72db6d8050a7ad13..e74dc501b27f1961c686635fdb4f98ed382dc79e 100644 (file)
@@ -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);
 }