Skip to content

Commit 0cc936f

Browse files
committed
io_uring: fix early fdput() of file
A previous commit shuffled some code around, and inadvertently used struct file after fdput() had been called on it. As we can't touch the file post fdput() dropping our reference, move the fdput() to after that has been done. Cc: Pavel Begunkov <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/io-uring/[email protected]/ Fixes: f2a48dd ("io_uring: refactor io_sq_offload_create()") Reported-by: Al Viro <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 362a9e6 commit 0cc936f

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

fs/io_uring.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7991,9 +7991,11 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
79917991
f = fdget(p->wq_fd);
79927992
if (!f.file)
79937993
return -ENXIO;
7994-
fdput(f);
7995-
if (f.file->f_op != &io_uring_fops)
7994+
if (f.file->f_op != &io_uring_fops) {
7995+
fdput(f);
79967996
return -EINVAL;
7997+
}
7998+
fdput(f);
79977999
}
79988000
if (ctx->flags & IORING_SETUP_SQPOLL) {
79998001
struct task_struct *tsk;

0 commit comments

Comments
 (0)