diff mbox series

selftests/bpf: don't close(-1) in serial_test_fexit_stress()

Message ID 20240623131753.2133829-1-make24@iscas.ac.cn
State Accepted
Commit d07980f7373b4c57c85478f8e815cc7b9b394c05
Headers show
Series selftests/bpf: don't close(-1) in serial_test_fexit_stress() | expand

Commit Message

Ma Ke June 23, 2024, 1:17 p.m. UTC
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>
---
 tools/testing/selftests/bpf/prog_tests/fexit_stress.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

patchwork-bot+netdevbpf@kernel.org June 26, 2024, 11:40 p.m. UTC | #1
Hello:

This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:

On Sun, 23 Jun 2024 21:17:53 +0800 you wrote:
> 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>
> ---
>  tools/testing/selftests/bpf/prog_tests/fexit_stress.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)

Here is the summary with links:
  - selftests/bpf: don't close(-1) in serial_test_fexit_stress()
    https://git.kernel.org/bpf/bpf-next/c/d07980f7373b

You are awesome, thank you!
diff mbox series

Patch

diff --git a/tools/testing/selftests/bpf/prog_tests/fexit_stress.c b/tools/testing/selftests/bpf/prog_tests/fexit_stress.c
index 596536def43d..94ff1d9fc9e4 100644
--- a/tools/testing/selftests/bpf/prog_tests/fexit_stress.c
+++ b/tools/testing/selftests/bpf/prog_tests/fexit_stress.c
@@ -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);