Skip to content

Commit

Permalink
selftests/bpf: Don't close(-1) in serial_test_fexit_stress()
Browse files Browse the repository at this point in the history
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
  • Loading branch information
Ma Ke authored and Andrii Nakryiko committed Jun 26, 2024
1 parent aa29398 commit d07980f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tools/testing/selftests/bpf/prog_tests/fexit_stress.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit d07980f

Please sign in to comment.