Skip to content

Commit 01ed88a

Browse files
Ming Leiaxboe
authored andcommitted
ublk: don't queue request if the associated uring_cmd is canceled
Commit 524346e ("ublk: build batch from IOs in same io_ring_ctx and io task") need to dereference `io->cmd` for checking if the IO can be added to current batch, see ublk_belong_to_same_batch() and io_uring_cmd_ctx_handle(). However, `io->cmd` may become invalid after the uring_cmd is canceled. Fixes it by only allowing to queue this IO in case that ublk_prep_req() returns `BLK_STS_OK`, when 'io->cmd' is guaranteed to be valid. Reported-by: Changhui Zhong <[email protected]> Fixes: 524346e ("ublk: build batch from IOs in same io_ring_ctx and io task") Signed-off-by: Ming Lei <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jens Axboe <[email protected]>
1 parent c007062 commit 01ed88a

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

drivers/block/ublk_drv.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1442,15 +1442,16 @@ static void ublk_queue_rqs(struct rq_list *rqlist)
14421442
struct ublk_queue *this_q = req->mq_hctx->driver_data;
14431443
struct ublk_io *this_io = &this_q->ios[req->tag];
14441444

1445+
if (ublk_prep_req(this_q, req, true) != BLK_STS_OK) {
1446+
rq_list_add_tail(&requeue_list, req);
1447+
continue;
1448+
}
1449+
14451450
if (io && !ublk_belong_to_same_batch(io, this_io) &&
14461451
!rq_list_empty(&submit_list))
14471452
ublk_queue_cmd_list(io, &submit_list);
14481453
io = this_io;
1449-
1450-
if (ublk_prep_req(this_q, req, true) == BLK_STS_OK)
1451-
rq_list_add_tail(&submit_list, req);
1452-
else
1453-
rq_list_add_tail(&requeue_list, req);
1454+
rq_list_add_tail(&submit_list, req);
14541455
}
14551456

14561457
if (!rq_list_empty(&submit_list))

0 commit comments

Comments
 (0)