]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
selftests/bpf: Fix cleanup in check_fd_array_cnt__fd_array_too_big()
authorIhor Solodrai <ihor.solodrai@linux.dev>
Mon, 23 Feb 2026 19:07:27 +0000 (11:07 -0800)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 24 Feb 2026 16:19:49 +0000 (08:19 -0800)
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>
tools/testing/selftests/bpf/prog_tests/fd_array.c

index c534b4d5f9da80e9b3a4b109f2c8fb581cca1db5..3078d8264debfb3b6447b2561c973e774beb38c5 100644 (file)
@@ -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)