]> git.baikalelectronics.ru Git - kernel.git/commitdiff
io_uring: ensure fput() called correspondingly when direct install fails
authorXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Fri, 27 May 2022 02:54:00 +0000 (10:54 +0800)
committerJens Axboe <axboe@kernel.dk>
Tue, 31 May 2022 08:50:06 +0000 (02:50 -0600)
io_fixed_fd_install() may fail for short of free fixed file bitmap,
in this case, need to call fput() correspondingly.

Signed-off-by: Xiaoguang Wang <xiaoguang.wang@linux.alibaba.com>
Link: https://lore.kernel.org/r/20220527025400.51048-1-xiaoguang.wang@linux.alibaba.com
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/io_uring.c

index 53683fa36a36a41d85232a14d8b8b22079731d12..1e5726b07b654c12e9b22136c184bee445fe8fab 100644 (file)
@@ -5438,6 +5438,10 @@ static int io_file_bitmap_get(struct io_ring_ctx *ctx)
        return -ENFILE;
 }
 
+/*
+ * Note when io_fixed_fd_install() returns error value, it will ensure
+ * fput() is called correspondingly.
+ */
 static int io_fixed_fd_install(struct io_kiocb *req, unsigned int issue_flags,
                               struct file *file, unsigned int file_slot)
 {
@@ -5450,6 +5454,7 @@ static int io_fixed_fd_install(struct io_kiocb *req, unsigned int issue_flags,
                ret = io_file_bitmap_get(ctx);
                if (unlikely(ret < 0)) {
                        io_ring_submit_unlock(ctx, issue_flags);
+                       fput(file);
                        return ret;
                }