From db4b040e1694500c9563539b3c634b30516203f9 Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Fri, 27 Sep 2024 09:22:58 -0600 Subject: [PATCH] test/poll-mshot-update: ensure 'nfiles' doesn't exceed NFILES Fixes: 4faa067d1c83 ("test/poll-mshot-update: make the test behave a bit better with file limits") Signed-off-by: Jens Axboe --- test/poll-mshot-update.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test/poll-mshot-update.c b/test/poll-mshot-update.c index 6ed98bd95..082e507f4 100644 --- a/test/poll-mshot-update.c +++ b/test/poll-mshot-update.c @@ -295,6 +295,8 @@ int main(int argc, char *argv[]) if (rlim.rlim_cur < (2 * NFILES + 5)) { rlim.rlim_cur = rlim.rlim_max; nfiles = (rlim.rlim_cur / 2) - 5; + if (nfiles > NFILES) + nfiles = NFILES; if (nfiles <= 0) goto err_nofail; if (setrlimit(RLIMIT_NOFILE, &rlim) < 0) {