From: Dan Carpenter <dan.carpenter@linaro.org>
To: Ming Lei <ming.lei@redhat.com>
Cc: Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org,
Andreas Hindborg <a.hindborg@samsung.com>
Subject: Re: [PATCH] ublk: fix 'warn: variable dereferenced before check 'req'' from Smatch
Date: Fri, 11 Aug 2023 17:44:13 +0300 [thread overview]
Message-ID: <f358d643-ec79-4ea5-910e-c21dce63218a@kadam.mountain> (raw)
In-Reply-To: <20230811135216.420404-1-ming.lei@redhat.com>
On Fri, Aug 11, 2023 at 09:52:16PM +0800, Ming Lei wrote:
> 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>
> ---
> drivers/block/ublk_drv.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/block/ublk_drv.c b/drivers/block/ublk_drv.c
> index 3650ef209344..be76db54db1f 100644
> --- a/drivers/block/ublk_drv.c
> +++ b/drivers/block/ublk_drv.c
> @@ -1400,11 +1400,13 @@ static void ublk_commit_completion(struct ublk_device *ub,
>
> /* find the io request and complete */
> req = blk_mq_tag_to_rq(ub->tag_set.tags[qid], tag);
> + if (WARN_ON_ONCE(unlikely(!req)))
WARN_ON_ONCE() already has an unlikely() built in.
regards,
dan carpenter
prev parent reply other threads:[~2023-08-11 14:44 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-11 13:52 [PATCH] ublk: fix 'warn: variable dereferenced before check 'req'' from Smatch Ming Lei
2023-08-11 14:13 ` Jens Axboe
2023-08-11 14:44 ` Dan Carpenter [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f358d643-ec79-4ea5-910e-c21dce63218a@kadam.mountain \
--to=dan.carpenter@linaro.org \
--cc=a.hindborg@samsung.com \
--cc=axboe@kernel.dk \
--cc=linux-block@vger.kernel.org \
--cc=ming.lei@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox