Skip to content

Commit 650b548

Browse files
isilenceaxboe
authored andcommitted
io_uring: don't prepare DRAIN reqs twice
If req->io is not NULL, it's already prepared. Don't do it again, it's dangerous. Signed-off-by: Pavel Begunkov <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 583863e commit 650b548

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

fs/io_uring.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5014,12 +5014,13 @@ static int io_req_defer(struct io_kiocb *req, const struct io_uring_sqe *sqe)
50145014
if (!req_need_defer(req) && list_empty_careful(&ctx->defer_list))
50155015
return 0;
50165016

5017-
if (!req->io && io_alloc_async_ctx(req))
5018-
return -EAGAIN;
5019-
5020-
ret = io_req_defer_prep(req, sqe);
5021-
if (ret < 0)
5022-
return ret;
5017+
if (!req->io) {
5018+
if (io_alloc_async_ctx(req))
5019+
return -EAGAIN;
5020+
ret = io_req_defer_prep(req, sqe);
5021+
if (ret < 0)
5022+
return ret;
5023+
}
50235024

50245025
spin_lock_irq(&ctx->completion_lock);
50255026
if (!req_need_defer(req) && list_empty(&ctx->defer_list)) {

0 commit comments

Comments
 (0)