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]
Date:   Mon, 28 Jan 2019 15:36:34 +0100
From:   Andrew Lunn <andrew@...n.ch>
To:     YueHaibing <yuehaibing@...wei.com>
Cc:     davem@...emloft.net, f.fainelli@...il.com, hkallweit1@...il.com,
        linux-kernel@...r.kernel.org, netdev@...r.kernel.org
Subject: Re: [PATCH net-next] mdio_bus: Fix PTR_ERR() usage after
 initialization to constant

On Mon, Jan 28, 2019 at 09:24:09PM +0800, YueHaibing wrote:
> Fix coccinelle warning:
> 
> ./drivers/net/phy/mdio_bus.c:51:5-12: ERROR: PTR_ERR applied after initialization to constant on line 44
> ./drivers/net/phy/mdio_bus.c:52:5-12: ERROR: PTR_ERR applied after initialization to constant on line 44
> 
> fix this by using IS_ERR before PTR_ERR
> 
> Fixes: bafbdd527d56 ("phylib: Add device reset GPIO support")
> Signed-off-by: YueHaibing <yuehaibing@...wei.com>
> ---
>  drivers/net/phy/mdio_bus.c | 13 ++++++++-----
>  1 file changed, 8 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
> index 3d31358..802716a 100644
> --- a/drivers/net/phy/mdio_bus.c
> +++ b/drivers/net/phy/mdio_bus.c
> @@ -42,17 +42,20 @@
>  static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
>  {
>  	struct gpio_desc *gpiod = NULL;
> +	int ret;
>  

Hi YueHaibing

I think i prefer the simpler fix:

 static int mdiobus_register_gpiod(struct mdio_device *mdiodev)
 {
-  	struct gpio_desc *gpiod = NULL;
+       struct gpio_desc *gpiod = ERR_PTR(-ENOENT);

Totally untested...

	Andrew

>  	/* Deassert the optional reset signal */
>  	if (mdiodev->dev.of_node)
>  		gpiod = fwnode_get_named_gpiod(&mdiodev->dev.of_node->fwnode,
>  					       "reset-gpios", 0, GPIOD_OUT_LOW,
>  					       "PHY reset");
> -	if (PTR_ERR(gpiod) == -ENOENT ||
> -	    PTR_ERR(gpiod) == -ENOSYS)
> -		gpiod = NULL;
> -	else if (IS_ERR(gpiod))
> -		return PTR_ERR(gpiod);
> +	if (IS_ERR(gpiod)) {
> +		ret = PTR_ERR(gpiod);
> +		if (ret == -ENOENT || ret == -ENOSYS)
> +			gpiod = NULL;
> +		else
> +			return ret;
> +	}
>  
>  	mdiodev->reset = gpiod;
>  
> -- 
> 2.7.4
> 
> 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ