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:   Tue, 3 Nov 2020 17:20:29 +0100
From:   Andrew Lunn <andrew@...n.ch>
To:     Radhey Shyam Pandey <radhey.shyam.pandey@...inx.com>
Cc:     davem@...emloft.net, kuba@...nel.org, michal.simek@...inx.com,
        netdev@...r.kernel.org, linux-arm-kernel@...ts.infradead.org,
        linux-kernel@...r.kernel.org, git@...inx.com,
        Shravya Kumbham <shravya.kumbham@...inx.com>
Subject: Re: [PATCH net-next] net: emaclite: Add error handling for
 of_address_ and phy read functions

On Tue, Nov 03, 2020 at 07:01:05PM +0530, Radhey Shyam Pandey wrote:
> From: Shravya Kumbham <shravya.kumbham@...inx.com>
> 
> Add ret variable, conditions to check the return value and it's error
> path for of_address_to_resource() and phy_read() functions.
> 
> Addresses-Coverity: Event check_return value.

Hi Radhey

This is well out of scope of a Coverity fix, but looking at the patch
i noticed some bad things.

> @@ -923,7 +929,7 @@ static int xemaclite_open(struct net_device *dev)
>  	xemaclite_disable_interrupts(lp);
>  
>  	if (lp->phy_node) {
> -		u32 bmcr;
> +		int bmcr;
>  
>  		lp->phy_dev = of_phy_connect(lp->ndev, lp->phy_node,
>  					     xemaclite_adjust_link, 0,
> @@ -945,6 +951,13 @@ static int xemaclite_open(struct net_device *dev)
>  
>  		/* Restart auto negotiation */
>  		bmcr = phy_read(lp->phy_dev, MII_BMCR);
> +		if (bmcr < 0) {
> +			dev_err(&lp->ndev->dev, "phy_read failed\n");
> +			phy_disconnect(lp->phy_dev);
> +			lp->phy_dev = NULL;
> +
> +			return bmcr;
> +		}
>  		bmcr |= (BMCR_ANENABLE | BMCR_ANRESTART);
>  		phy_write(lp->phy_dev, MII_BMCR, bmcr);

A MAC driver should not be touching the PHY. The call to
phy_set_max_speed() should prevent the PHY from advertising 1G speeds,
so there is no need to poke the advertise registers. And phy_start()
will start auto-get if it is enabled.

It would be nice if this code got cleaned up.

   Andrew

Powered by blists - more mailing lists