Commit 3eb4a2e3 authored by Ihor Solodrai's avatar Ihor Solodrai Committed by Alexei Starovoitov
Browse files

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: default avatarEduard Zingerman <eddyz87@gmail.com>
Signed-off-by: default avatarIhor Solodrai <ihor.solodrai@linux.dev>
Link: https://lore.kernel.org/r/20260223190736.649171-12-ihor.solodrai@linux.dev


Signed-off-by: default avatarAlexei Starovoitov <ast@kernel.org>
parent 9d0272c9
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -412,8 +412,8 @@ static void check_fd_array_cnt__fd_array_too_big(void)
	ASSERT_EQ(prog_fd, -E2BIG, "prog should have been rejected with -E2BIG");

cleanup_fds:
	while (i > 0)
		Close(extra_fds[--i]);
	while (i-- > 0)
		Close(extra_fds[i]);
}

void test_fd_array_cnt(void)