Skip to contentSkip to conversation

net: macb: NULL out phydev after removing mdio bus

PATCH Applied Xander Huff 4 participants 4 messages Oct 7, 2016 – Oct 8, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: macb: NULL out phydev after removing mdio bus

From: Nathan Sullivan <[email protected]>

To ensure the dev->phydev pointer is not used after becoming invalid in mdiobus_unregister, set it to NULL. This happens when removing the macb driver without first taking its interface down, since unregister_netdev will end up calling macb_close.

---
 drivers/net/ethernet/cadence/macb.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/cadence/macb.c +1 -0
index 63144bb..b32444a 100644
@@ -3117,6 +3117,7 @@ static int macb_remove(struct platform_device *pdev)
 		if (dev->phydev)
 			phy_disconnect(dev->phydev);
 		mdiobus_unregister(bp->mii_bus);
+		dev->phydev = NULL;
 		mdiobus_free(bp->mii_bus);
 
 		/* Shutdown the PHY if there is a GPIO reset */
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Xander Huff

From: Nathan Sullivan <[email protected]>

To ensure the dev->phydev pointer is not used after becoming invalid in mdiobus_unregister, set it to NULL. This happens when removing the macb driver without first taking its interface down, since unregister_netdev will end up calling macb_close.

Acked-by on v1 1/1
#2 lore raw
In reply to Xander Huff
Quoted 10 lines · Xander Huff

From: Nathan Sullivan <[email protected]>

To ensure the dev->phydev pointer is not used after becoming invalid in mdiobus_unregister, set it to NULL. This happens when removing the macb driver without first taking its interface down, since unregister_netdev will end up calling macb_close.

Quoted 17 lines
---
 drivers/net/ethernet/cadence/macb.c | 1 +
 1 file changed, 1 insertion(+)
drivers/net/ethernet/cadence/macb.c +1 -0
index 63144bb..b32444a 100644
@@ -3117,6 +3117,7 @@ static int macb_remove(struct platform_device *pdev)
 		if (dev->phydev)
 			phy_disconnect(dev->phydev);
 		mdiobus_unregister(bp->mii_bus);
+		dev->phydev = NULL;
 		mdiobus_free(bp->mii_bus);
 
 		/* Shutdown the PHY if there is a GPIO reset */
Signature · 1 line
Nicolas Ferre
maintainer Applied
#3 lore raw
In reply to Xander Huff

From: Xander Huff <[email protected]>
Date: Fri, 7 Oct 2016 10:13:22 -0500

Quoted 10 lines

From: Nathan Sullivan <[email protected]>

To ensure the dev->phydev pointer is not used after becoming invalid in mdiobus_unregister, set it to NULL. This happens when removing the macb driver without first taking its interface down, since unregister_netdev will end up calling macb_close.

Applied.