summaryrefslogtreecommitdiff
path: root/fs/io_uring.c
diff options
context:
space:
mode:
authorXiaoguang Wang <xiaoguang.wang@linux.alibaba.com>2022-05-27 10:54:00 +0800
committerJens Axboe <axboe@kernel.dk>2022-05-31 02:50:06 -0600
commit8c71fe750215e688df9c7477e7bf448380d4ce9e (patch)
tree4ca6a44ca024e4892ce302a231b68b0dd27eba1a /fs/io_uring.c
parentfa82dd105bed389f37d919fd783ce459bb92facb (diff)
io_uring: ensure fput() called correspondingly when direct install fails
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>
Diffstat (limited to 'fs/io_uring.c')
-rw-r--r--fs/io_uring.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/fs/io_uring.c b/fs/io_uring.c
index 53683fa36a36..1e5726b07b65 100644
--- a/fs/io_uring.c
+++ b/fs/io_uring.c
@@ -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;
}