Skip to contentSkip to conversation

io_uring: fix early fdput() of file

PATCH New Jens Axboe 1 participant 1 message Jul 22, 2021

Subsystems (2)
lore
Share & tools
lore

Jens Axboe

author maintainer
#0 lore raw

PATCH 1/1 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]>
Fixes f2a48dd09b8e ("io_uring: refactor io_sq_offload_create()")

---

fs/io_uring.c +4 -2
index fe3d948658ad..f2fe4eca150b 100644
@@ -7991,9 +7991,11 @@ static int io_sq_offload_create(struct io_ring_ctx *ctx,
 		f = fdget(p->wq_fd);
 		if (!f.file)
 			return -ENXIO;
-		fdput(f);
-		if (f.file->f_op != &io_uring_fops)
+		if (f.file->f_op != &io_uring_fops) {
+			fdput(f);
 			return -EINVAL;
+		}
+		fdput(f);
 	}
 	if (ctx->flags & IORING_SETUP_SQPOLL) {
 		struct task_struct *tsk;
Signature · 1 line
Jens Axboe