]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
io_uring: fix spurious fput in registered ring path
authorJens Axboe <axboe@kernel.dk>
Mon, 20 Apr 2026 14:06:00 +0000 (14:06 +0000)
committerJens Axboe <axboe@kernel.dk>
Tue, 21 Apr 2026 18:18:44 +0000 (12:18 -0600)
Fix an issue with io_uring_ctx_get_file() not gating fput() on whether
or not the file descriptor is a registered/direct one or not.

Fixes: c5e9f6a96bf7 ("io_uring: unify getting ctx from passed in file descriptor")
Reviewed-by: Gabriel Krisman Bertazi <krisman@suse.de>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
io_uring/io_uring.c

index dd6326dc5f88f9d68b7395b5cd8109e9fdf9a6a4..4ed998d60c09cb0706d23ce5e9a5c9da5e282607 100644 (file)
@@ -2575,7 +2575,8 @@ struct file *io_uring_ctx_get_file(unsigned int fd, bool registered)
                return ERR_PTR(-EBADF);
        if (io_is_uring_fops(file))
                return file;
-       fput(file);
+       if (!registered)
+               fput(file);
        return ERR_PTR(-EOPNOTSUPP);
 }