]> git.baikalelectronics.ru Git - kernel.git/commitdiff
net: phy: smsc: bail out in lan87xx_read_status if genphy_read_status fails
authorHeiner Kallweit <hkallweit1@gmail.com>
Sat, 11 Mar 2023 18:34:45 +0000 (19:34 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Mar 2023 12:33:46 +0000 (13:33 +0100)
[ Upstream commit f27186800cf0716a021930dd310d4a7a1c2b77d0 ]

If genphy_read_status fails then further access to the PHY may result
in unpredictable behavior. To prevent this bail out immediately if
genphy_read_status fails.

Fixes: 1dab61124363 ("net: phy: smsc: Re-enable EDPD mode for LAN87xx")
Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Reviewed-by: Simon Horman <simon.horman@corigine.com>
Link: https://lore.kernel.org/r/026aa4f2-36f5-1c10-ab9f-cdb17dda6ac4@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/phy/smsc.c

index 00d9eff91dcfaf34c4fae700e6d7dbcbc97f22cd..df2c5435c5c49ee828d625c36e39f4e2d2af0216 100644 (file)
@@ -199,8 +199,11 @@ static int lan95xx_config_aneg_ext(struct phy_device *phydev)
 static int lan87xx_read_status(struct phy_device *phydev)
 {
        struct smsc_phy_priv *priv = phydev->priv;
+       int err;
 
-       int err = genphy_read_status(phydev);
+       err = genphy_read_status(phydev);
+       if (err)
+               return err;
 
        if (!phydev->link && priv->energy_enable && phydev->irq == PHY_POLL) {
                /* Disable EDPD to wake up PHY */