Commit 0cc936f7 authored by Jens Axboe's avatar Jens Axboe

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 <asml.silence@gmail.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/io-uring/YPnqM0fY3nM5RdRI@zeniv-ca.linux.org.uk/
Fixes: f2a48dd0 ("io_uring: refactor io_sq_offload_create()")
Reported-by: default avatarAl Viro <viro@zeniv.linux.org.uk>
Signed-off-by: default avatarJens Axboe <axboe@kernel.dk>
parent 362a9e65
...@@ -7991,10 +7991,12 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx, ...@@ -7991,10 +7991,12 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
f = fdget(p->wq_fd); f = fdget(p->wq_fd);
if (!f.file) if (!f.file)
return -ENXIO; return -ENXIO;
if (f.file->f_op != &io_uring_fops) {
fdput(f); fdput(f);
if (f.file->f_op != &io_uring_fops)
return -EINVAL; return -EINVAL;
} }
fdput(f);
}
if (ctx->flags & IORING_SETUP_SQPOLL) { if (ctx->flags & IORING_SETUP_SQPOLL) {
struct task_struct *tsk; struct task_struct *tsk;
struct io_sq_data *sqd; struct io_sq_data *sqd;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment