[PATCH net] net: phy: bcm84881: Fix some error handling paths

Christophe JAILLET posted 1 patch 1 month, 3 weeks ago
drivers/net/phy/bcm84881.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
[PATCH net] net: phy: bcm84881: Fix some error handling paths
Posted by Christophe JAILLET 1 month, 3 weeks ago
If phy_read_mmd() fails, the error code stored in 'bmsr' should be returned
instead of 'val' which is likely to be 0.

Fixes: 75f4d8d10e01 ("net: phy: add Broadcom BCM84881 PHY driver")
Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>
---
This patch is speculative.
---
 drivers/net/phy/bcm84881.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/phy/bcm84881.c b/drivers/net/phy/bcm84881.c
index f1d47c264058..97da3aee4942 100644
--- a/drivers/net/phy/bcm84881.c
+++ b/drivers/net/phy/bcm84881.c
@@ -132,7 +132,7 @@ static int bcm84881_aneg_done(struct phy_device *phydev)
 
 	bmsr = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_C22 + MII_BMSR);
 	if (bmsr < 0)
-		return val;
+		return bmsr;
 
 	return !!(val & MDIO_AN_STAT1_COMPLETE) &&
 	       !!(bmsr & BMSR_ANEGCOMPLETE);
@@ -158,7 +158,7 @@ static int bcm84881_read_status(struct phy_device *phydev)
 
 	bmsr = phy_read_mmd(phydev, MDIO_MMD_AN, MDIO_AN_C22 + MII_BMSR);
 	if (bmsr < 0)
-		return val;
+		return bmsr;
 
 	phydev->autoneg_complete = !!(val & MDIO_AN_STAT1_COMPLETE) &&
 				   !!(bmsr & BMSR_ANEGCOMPLETE);
-- 
2.46.2
Re: [PATCH net] net: phy: bcm84881: Fix some error handling paths
Posted by Florian Fainelli 1 month, 3 weeks ago
On 10/3/24 12:03, Christophe JAILLET wrote:
> If phy_read_mmd() fails, the error code stored in 'bmsr' should be returned
> instead of 'val' which is likely to be 0.
> 
> Fixes: 75f4d8d10e01 ("net: phy: add Broadcom BCM84881 PHY driver")
> Signed-off-by: Christophe JAILLET <christophe.jaillet@wanadoo.fr>

Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com>
--
Florian