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] [day] [month] [year] [list]
Message-ID: <683a0713-2587-17e4-6280-b2f905b3a230@gmail.com>
Date:   Mon, 13 Jul 2020 19:55:32 -0700
From:   Florian Fainelli <f.fainelli@...il.com>
To:     Xu Wang <vulab@...as.ac.cn>, davem@...emloft.net, kuba@...nel.org,
        michal.simek@...inx.com, esben@...nix.com, hkallweit1@...il.com,
        weiyongjun1@...wei.com, netdev@...r.kernel.org,
        linux-arm-kernel@...ts.infradead.org
Cc:     linux-kernel@...r.kernel.org
Subject: Re: [PATCH] net: xilinx: fix potential NULL dereference in
 temac_probe()



On 7/13/2020 7:23 PM, Xu Wang wrote:
> platform_get_resource() may return NULL, add proper
> check to avoid potential NULL dereferencing.
> 
> Signed-off-by: Xu Wang <vulab@...as.ac.cn>
> ---

If you use devm_ioremap_resource() you can remove the !res check
entirely which would be equally acceptable as a fix.

>  drivers/net/ethernet/xilinx/ll_temac_main.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/drivers/net/ethernet/xilinx/ll_temac_main.c b/drivers/net/ethernet/xilinx/ll_temac_main.c
> index 929244064abd..85a767fa2ecf 100644
> --- a/drivers/net/ethernet/xilinx/ll_temac_main.c
> +++ b/drivers/net/ethernet/xilinx/ll_temac_main.c
> @@ -1408,6 +1408,8 @@ static int temac_probe(struct platform_device *pdev)
>  
>  	/* map device registers */
>  	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> +	if (!res)
> +		return -EINVAL;
>  	lp->regs = devm_ioremap(&pdev->dev, res->start,
>  					resource_size(res));
>  	if (!lp->regs) {
> @@ -1503,6 +1505,8 @@ static int temac_probe(struct platform_device *pdev)
>  	} else if (pdata) {
>  		/* 2nd memory resource specifies DMA registers */
>  		res = platform_get_resource(pdev, IORESOURCE_MEM, 1);
> +		if (!res)
> +			return -EINVAL;
>  		lp->sdma_regs = devm_ioremap(&pdev->dev, res->start,
>  						     resource_size(res));
>  		if (!lp->sdma_regs) {
> 

-- 
Florian

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ