Skip to contentSkip to conversation

phylib: fix PAL state machine restart on resume

PATCH Applied Simon Guinot 2 participants 2 messages Sep 14, 2010

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

PATCH 1/1 phylib: fix PAL state machine restart on resume

From: Simon Guinot <[email protected]>

On resume, before starting the PAL state machine, check if the adjust_link() method is well supplied. If not, this would lead to a NULL pointer dereference in the phy_state_machine() function.

This scenario can happen if the Ethernet driver call manually the PHY functions instead of using the PAL state machine. The mv643xx_eth driver is a such example.

---
 drivers/net/phy/mdio_bus.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/mdio_bus.c +2 -2
index 6a6b819..6c58da2 100644
@@ -308,7 +308,7 @@ static int mdio_bus_suspend(struct device *dev)
 	 * may call phy routines that try to grab the same lock, and that may
 	 * lead to a deadlock.
 	 */
-	if (phydev->attached_dev)
+	if (phydev->attached_dev && phydev->adjust_link)
 		phy_stop_machine(phydev);
 
 	if (!mdio_bus_phy_may_suspend(phydev))
@@ -331,7 +331,7 @@ static int mdio_bus_resume(struct device *dev)
 		return ret;
 
 no_resume:
-	if (phydev->attached_dev)
+	if (phydev->attached_dev && phydev->adjust_link)
 		phy_start_machine(phydev, NULL);
 
 	return 0;
Signature · 1 line
1.6.3.1
maintainer Applied
#1 lore raw

From: Simon Guinot <[email protected]>
Date: Tue, 14 Sep 2010 10:12:01 +0200

Quoted 11 lines

From: Simon Guinot <[email protected]>

On resume, before starting the PAL state machine, check if the adjust_link() method is well supplied. If not, this would lead to a NULL pointer dereference in the phy_state_machine() function.

This scenario can happen if the Ethernet driver call manually the PHY functions instead of using the PAL state machine. The mv643xx_eth driver is a such example.

Applied, thanks.