提交 0075bd69 编写于 作者: G Geert Uytterhoeven 提交者: David S. Miller

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: 2e0bc452 ("net: phy: leds: add support for led triggers on phy link state change")
Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
Tested-by: NZach Brown <zach.brown@ni.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 22d3efe5
......@@ -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.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册