lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1ce29a1e-2db7-2953-b71e-c0408559ecff@gmail.com>
Date:   Wed, 24 Aug 2022 10:15:56 +0200
From:   Niels Dossche <dossche.niels@...il.com>
To:     cgel.zte@...il.com, dennis.dalessandro@...nelisnetworks.com
Cc:     jgg@...pe.ca, leon@...nel.org, linux-rdma@...r.kernel.org,
        linux-kernel@...r.kernel.org, Minghao Chi <chi.minghao@....com.cn>,
        Zeal Robot <zealci@....com.cn>
Subject: Re: [PATCH] infiniband: remove unnecessary null check

On 8/24/22 10:05, cgel.zte@...il.com wrote:
> From: Minghao Chi <chi.minghao@....com.cn>
> 
> container_of is never null, so this null check is
> unnecessary.
> 
> Reported-by: Zeal Robot <zealci@....com.cn>
> Signed-off-by: Minghao Chi <chi.minghao@....com.cn>
> ---
>  drivers/infiniband/sw/rdmavt/vt.c | 2 --
>  1 file changed, 2 deletions(-)
> 
> diff --git a/drivers/infiniband/sw/rdmavt/vt.c b/drivers/infiniband/sw/rdmavt/vt.c
> index 59481ae39505..b2d83b4958fc 100644
> --- a/drivers/infiniband/sw/rdmavt/vt.c
> +++ b/drivers/infiniband/sw/rdmavt/vt.c
> @@ -50,8 +50,6 @@ struct rvt_dev_info *rvt_alloc_device(size_t size, int nports)
>  	struct rvt_dev_info *rdi;
>  
>  	rdi = container_of(_ib_alloc_device(size), struct rvt_dev_info, ibdev);
> -	if (!rdi)
> -		return rdi;
>  
>  	rdi->ports = kcalloc(nports, sizeof(*rdi->ports), GFP_KERNEL);
>  	if (!rdi->ports)

I believe this patch is incorrect because "_ib_alloc_device" may return a null pointer.
Note that the first member of "rvt_dev_info" is "ib_device", so the check on container_of effectively checks if the allocation failed, which is necessary to check.

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ