Skip to content

Commit c2b727d

Browse files
ffainellidavem330
authored andcommitted
net: phy: Avoid NPD upon phy_detach() when driver is unbound
If we have unbound the PHY driver prior to calling phy_detach() (often via phy_disconnect()) then we can cause a NULL pointer de-reference accessing the driver owner member. The steps to reproduce are: echo unimac-mdio-0:01 > /sys/class/net/eth0/phydev/driver/unbind ip link set eth0 down Fixes: cafe8df ("net: phy: Fix lack of reference count on PHY driver") Signed-off-by: Florian Fainelli <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 19a83d3 commit c2b727d

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

drivers/net/phy/phy_device.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1682,7 +1682,8 @@ void phy_detach(struct phy_device *phydev)
16821682

16831683
phy_led_triggers_unregister(phydev);
16841684

1685-
module_put(phydev->mdio.dev.driver->owner);
1685+
if (phydev->mdio.dev.driver)
1686+
module_put(phydev->mdio.dev.driver->owner);
16861687

16871688
/* If the device had no specific driver before (i.e. - it
16881689
* was using the generic driver), we unbind the device

0 commit comments

Comments
 (0)