Skip to contentSkip to conversation

net: phy: smsc: bail out in lan87xx_read_status if genphy_read_status fails

PATCH Applied Heiner Kallweit 3 participants 3 messages Mar 11, 2023 – Mar 15, 2023

Subsystems (3)
lore
Share & tools
lore

Heiner Kallweit

author maintainer
#0 lore raw

PATCH 1/1 net: phy: smsc: bail out in lan87xx_read_status if genphy_read_status fails

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 4223dbffed9f ("net: phy: smsc: Re-enable EDPD mode for LAN87xx")
---
 drivers/net/phy/smsc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/phy/smsc.c +4 -1
index 9cfaccce1..721871184 100644
@@ -189,8 +189,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 */
Signature · 1 line
2.39.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Heiner Kallweit

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 4223dbffed9f ("net: phy: smsc: Re-enable EDPD mode for LAN87xx")
Quoted 23 lines
---
 drivers/net/phy/smsc.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/net/phy/smsc.c +4 -1
index 9cfaccce1..721871184 100644
@@ -189,8 +189,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 */
Signature · 1 line
2.39.2
#2 lore raw
In reply to Heiner Kallweit
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Sat, 11 Mar 2023 19:34:45 +0100 you wrote:

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 4223dbffed9f ("net: phy: smsc: Re-enable EDPD mode for LAN87xx")

[...]

Here is the summary with links:
- [net] net: phy: smsc: bail out in lan87xx_read_status if genphy_read_status fails

    https://git.kernel.org/netdev/net/c/c22c3bbf351e

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html