]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
net: phy: Fix PHY unbind crash
authorFlorian Fainelli <f.fainelli@gmail.com>
Sat, 18 Feb 2017 00:07:33 +0000 (16:07 -0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 20 Feb 2017 15:15:11 +0000 (10:15 -0500)
The PHY library does not deal very well with bind and unbind events. The first
thing we would see is that we were not properly canceling the PHY state machine
workqueue, so we would be crashing while dereferencing phydev->drv since there
is no driver attached anymore.

Suggested-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: Florian Fainelli <f.fainelli@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/phy/phy_device.c

index 8c8e15b8739dec0ae96d72b514045a99eb1ed7e1..7f9319586b7e0b5f30e41225f055058d55fca8b1 100644 (file)
@@ -1784,6 +1784,8 @@ static int phy_remove(struct device *dev)
 {
        struct phy_device *phydev = to_phy_device(dev);
 
+       cancel_delayed_work_sync(&phydev->state_queue);
+
        mutex_lock(&phydev->lock);
        phydev->state = PHY_DOWN;
        mutex_unlock(&phydev->lock);