public inbox for linux-block@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ublk: remove unnecessary checks in ublk_check_and_get_req()
@ 2025-11-08 22:17 Caleb Sander Mateos
  2025-11-09 14:10 ` Ming Lei
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Caleb Sander Mateos @ 2025-11-08 22:17 UTC (permalink / raw)
  To: Ming Lei, Jens Axboe; +Cc: Caleb Sander Mateos, linux-block, linux-kernel

ub = iocb->ki_filp->private_data cannot be NULL, as it's set in
ublk_ch_open() before it returns succesfully. req->mq_hctx cannot be
NULL as any inflight ublk request must belong to some queue. And
req->mq_hctx->driver_data cannot be NULL as it's set to the ublk_queue
pointer in ublk_init_hctx(). So drop the unnecessary checks.

Signed-off-by: Caleb Sander Mateos <csander@purestorage.com>
---
 drivers/block/ublk_drv.c | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
index 5cf288809226..30e798f062ef 100644
--- a/drivers/block/ublk_drv.c
+++ b/drivers/block/ublk_drv.c
@@ -2506,13 +2506,10 @@ static struct request *ublk_check_and_get_req(struct kiocb *iocb,
 	struct ublk_queue *ubq;
 	struct request *req;
 	size_t buf_off;
 	u16 tag, q_id;
 
-	if (!ub)
-		return ERR_PTR(-EACCES);
-
 	if (!user_backed_iter(iter))
 		return ERR_PTR(-EACCES);
 
 	if (ub->dev_info.state == UBLK_S_DEV_DEAD)
 		return ERR_PTR(-EACCES);
@@ -2534,13 +2531,10 @@ static struct request *ublk_check_and_get_req(struct kiocb *iocb,
 	*io = &ubq->ios[tag];
 	req = __ublk_check_and_get_req(ub, q_id, tag, *io, buf_off);
 	if (!req)
 		return ERR_PTR(-EINVAL);
 
-	if (!req->mq_hctx || !req->mq_hctx->driver_data)
-		goto fail;
-
 	if (!ublk_check_ubuf_dir(req, dir))
 		goto fail;
 
 	*off = buf_off;
 	return req;
-- 
2.45.2


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-11 14:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-08 22:17 [PATCH] ublk: remove unnecessary checks in ublk_check_and_get_req() Caleb Sander Mateos
2025-11-09 14:10 ` Ming Lei
2025-11-09 17:58 ` Chaitanya Kulkarni
2025-11-11 14:59 ` Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox