ublk: fix 'warn: variable dereferenced before check 'req'' from Smatch
authorMing Lei <ming.lei@redhat.com>
Fri, 11 Aug 2023 13:52:16 +0000 (21:52 +0800)
committerJens Axboe <axboe@kernel.dk>
Fri, 11 Aug 2023 14:13:23 +0000 (08:13 -0600)
commite24721e441a7c640e4e7b2b63c23c06d9a750880
tree5911a0eff83930b086aed0c8d0ba564dc4a2d9ff
parent18267a0365d6ec8bbe85ba8cbea5af12d9e59610
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: 29802d7ca33b ("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>
drivers/block/ublk_drv.c