aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJens Axboe <axboe@kernel.dk>2024-03-26 16:38:19 -0600
committerJens Axboe <axboe@kernel.dk>2024-03-26 16:38:19 -0600
commita8e5f9583ae7383bcd9edfed319c9480221514ad (patch)
tree1d085e04601278bef27a75a47c59118785367134
parentd139187eb1c4e8bd01725498b2e1272e7134d6c9 (diff)
downloadliburing-a8e5f9583ae7383bcd9edfed319c9480221514ad.tar.gz
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>
-rw-r--r--test/file-register.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/test/file-register.c b/test/file-register.c
index f48eceb4..8685732d 100644
--- a/test/file-register.c
+++ b/test/file-register.c
@@ -352,10 +352,14 @@ err:
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) {