]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
selftests/bpf: Don't close(-1) in serial_test_fexit_stress()
authorMa Ke <make24@iscas.ac.cn>
Sun, 23 Jun 2024 13:17:53 +0000 (21:17 +0800)
committerAndrii Nakryiko <andrii@kernel.org>
Wed, 26 Jun 2024 23:36:59 +0000 (16:36 -0700)
Guard close() with extra link_fd[i] > 0 and fexit_fd[i] > 0
check to prevent close(-1).

Signed-off-by: Ma Ke <make24@iscas.ac.cn>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Link: https://lore.kernel.org/bpf/20240623131753.2133829-1-make24@iscas.ac.cn
tools/testing/selftests/bpf/prog_tests/fexit_stress.c

index 596536def43d49029a9aaf3944eb508eb75b76a7..49b1ffc9af1f5e78910a2be8b9c2fd9be355e992 100644 (file)
@@ -50,9 +50,9 @@ void serial_test_fexit_stress(void)
 
 out:
        for (i = 0; i < bpf_max_tramp_links; i++) {
-               if (link_fd[i])
+               if (link_fd[i] > 0)
                        close(link_fd[i]);
-               if (fexit_fd[i])
+               if (fexit_fd[i] > 0)
                        close(fexit_fd[i]);
        }
        free(fd);