Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

phylib: fix PAL state machine restart on resume

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.

Signed-off-by: Simon Guinot <sguinot@lacie.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Simon Guinot and committed by
David S. Miller
fddd9101 ef885afb

+2 -2
+2 -2
drivers/net/phy/mdio_bus.c
··· 308 308 * may call phy routines that try to grab the same lock, and that may 309 309 * lead to a deadlock. 310 310 */ 311 - if (phydev->attached_dev) 311 + if (phydev->attached_dev && phydev->adjust_link) 312 312 phy_stop_machine(phydev); 313 313 314 314 if (!mdio_bus_phy_may_suspend(phydev)) ··· 331 331 return ret; 332 332 333 333 no_resume: 334 - if (phydev->attached_dev) 334 + if (phydev->attached_dev && phydev->adjust_link) 335 335 phy_start_machine(phydev, NULL); 336 336 337 337 return 0;