Skip to content

Commit e24721e

Browse files
Ming Leiaxboe
authored andcommitted
ublk: fix 'warn: variable dereferenced before check 'req'' from Smatch
The added check of 'req_op(req) == REQ_OP_ZONE_APPEND' should have been done after the request is confirmed as valid. Actually here, the request should always been true, so add one WARN_ON_ONCE(!req), meantime move the zone_append check after checking the request. Cc: Andreas Hindborg <a.hindborg@samsung.com> Reported-by: Dan Carpenter <dan.carpenter@linaro.org> Fixes: 29802d7 ("ublk: enable zoned storage support") Signed-off-by: Ming Lei <ming.lei@redhat.com> Link: https://lore.kernel.org/r/20230811135216.420404-1-ming.lei@redhat.com Signed-off-by: Jens Axboe <axboe@kernel.dk>
1 parent 18267a0 commit e24721e

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

drivers/block/ublk_drv.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1397,11 +1397,13 @@ static void ublk_commit_completion(struct ublk_device *ub,
13971397

13981398
/* find the io request and complete */
13991399
req = blk_mq_tag_to_rq(ub->tag_set.tags[qid], tag);
1400+
if (WARN_ON_ONCE(unlikely(!req)))
1401+
return;
14001402

14011403
if (req_op(req) == REQ_OP_ZONE_APPEND)
14021404
req->__sector = ub_cmd->zone_append_lba;
14031405

1404-
if (req && likely(!blk_should_fake_timeout(req->q)))
1406+
if (likely(!blk_should_fake_timeout(req->q)))
14051407
ublk_put_req_ref(ubq, req);
14061408
}
14071409

0 commit comments

Comments
 (0)