Re: [PATCH] ublk: fix 'warn: variable dereferenced before check 'req'' from Smatch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>
> Reported-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
> Fixes: 29802d7ca33b ("ublk: enable zoned storage support")
> Signed-off-by: Ming Lei <ming.lei@xxxxxxxxxx>
> ---
>  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




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux