test/file-register: ensure the fail case allocates enough
For the fail case, we only allocate 10 descriptors, yet still try
and use 100 in the array. Allocate enough and ensure that we clear
them to -2 as well, as the default clear of -1 means "sparse
placeholder" for the file registration code.
Reported-by: Manu Bretelle <chantra@meta.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/test/file-register.c b/test/file-register.c
index f48eceb..8685732 100644
--- a/test/file-register.c
+++ b/test/file-register.c
@@ -352,10 +352,14 @@
static int test_basic(struct io_uring *ring, int fail)
{
int *files;
- int ret;
+ int ret, i;
int nr_files = fail ? 10 : 100;
- files = open_files(nr_files, 0, 0);
+ files = open_files(nr_files, fail ? 90 : 0, 0);
+ if (fail) {
+ for (i = nr_files; i < nr_files + 90; i++)
+ files[i] = -2;
+ }
ret = io_uring_register_files(ring, files, 100);
if (ret) {
if (fail) {