Skip to content

Commit 3eb4a2e

Browse files
theihorAlexei Starovoitov
authored andcommitted
selftests/bpf: Fix cleanup in check_fd_array_cnt__fd_array_too_big()
The Close() macro uses the passed in expression three times, which leads to repeated execution in case it has side effects. That is, Close(i--) would decrement i three times. ASAN caught a stack-buffer-undeflow error at a point where this was overlooked. Fix it. Acked-by: Eduard Zingerman <eddyz87@gmail.com> Signed-off-by: Ihor Solodrai <ihor.solodrai@linux.dev> Link: https://lore.kernel.org/r/20260223190736.649171-12-ihor.solodrai@linux.dev Signed-off-by: Alexei Starovoitov <ast@kernel.org>
1 parent 9d0272c commit 3eb4a2e

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

tools/testing/selftests/bpf/prog_tests/fd_array.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,8 @@ static void check_fd_array_cnt__fd_array_too_big(void)
412412
ASSERT_EQ(prog_fd, -E2BIG, "prog should have been rejected with -E2BIG");
413413

414414
cleanup_fds:
415-
while (i > 0)
416-
Close(extra_fds[--i]);
415+
while (i-- > 0)
416+
Close(extra_fds[i]);
417417
}
418418

419419
void test_fd_array_cnt(void)

0 commit comments

Comments
 (0)