diff options
author | Geert Uytterhoeven <geert+renesas@glider.be> | 2016-11-28 15:18:31 +0100 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2016-11-29 20:35:24 -0500 |
commit | 0075bd692dca037108fd8b5d90a68d34bad4c2f8 (patch) | |
tree | e944e0663f0535a97b35bfb0cb69bbe6ea89320e /drivers/net/phy/phy_device.c | |
parent | 22d3efe5f62e048eb2c85b9ef24e3b7af545a458 (diff) | |
download | blackbird-op-linux-0075bd692dca037108fd8b5d90a68d34bad4c2f8.tar.gz blackbird-op-linux-0075bd692dca037108fd8b5d90a68d34bad4c2f8.zip |
net: phy: Fix use after free in phy_detach()
If device_release_driver(&phydev->mdio.dev) is called, it releases all
resources belonging to the PHY device. Hence the subsequent call to
phy_led_triggers_unregister() will access already freed memory when
unregistering the LEDs.
Move the call to phy_led_triggers_unregister() before the possible call
to device_release_driver() to fix this.
Fixes: 2e0bc452f4721520 ("net: phy: leds: add support for led triggers on phy link state change")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Tested-by: Zach Brown <zach.brown@ni.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/phy/phy_device.c')
-rw-r--r-- | drivers/net/phy/phy_device.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 83e52f1b80f2..aeaf1bcb12d0 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -981,6 +981,8 @@ void phy_detach(struct phy_device *phydev) phydev->attached_dev = NULL; phy_suspend(phydev); + phy_led_triggers_unregister(phydev); + /* If the device had no specific driver before (i.e. - it * was using the generic driver), we unbind the device * from the generic driver so that there's a chance a @@ -994,8 +996,6 @@ void phy_detach(struct phy_device *phydev) } } - phy_led_triggers_unregister(phydev); - /* * The phydev might go away on the put_device() below, so avoid * a use-after-free bug by reading the underlying bus first. |