Skip to content

Commit 8c71fe7

Browse files
Xiaoguang Wangaxboe
Xiaoguang Wang
authored andcommitted
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>
1 parent fa82dd1 commit 8c71fe7

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

fs/io_uring.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5438,6 +5438,10 @@ static int io_file_bitmap_get(struct io_ring_ctx *ctx)
54385438
return -ENFILE;
54395439
}
54405440

5441+
/*
5442+
* Note when io_fixed_fd_install() returns error value, it will ensure
5443+
* fput() is called correspondingly.
5444+
*/
54415445
static int io_fixed_fd_install(struct io_kiocb *req, unsigned int issue_flags,
54425446
struct file *file, unsigned int file_slot)
54435447
{
@@ -5450,6 +5454,7 @@ static int io_fixed_fd_install(struct io_kiocb *req, unsigned int issue_flags,
54505454
ret = io_file_bitmap_get(ctx);
54515455
if (unlikely(ret < 0)) {
54525456
io_ring_submit_unlock(ctx, issue_flags);
5457+
fput(file);
54535458
return ret;
54545459
}
54555460

0 commit comments

Comments
 (0)