Revert "net: mdio_bus: Use devm for getting reset GPIO"
Subsystems (3)
Jakub Kicinski
maintainerPATCH 1/1 Revert "net: mdio_bus: Use devm for getting reset GPIO"
This reverts commit 3b98c9352511db627b606477fc7944b2fa53a165.
Russell says:
Using devm_*() [here] is completely wrong, because this is called from mdiobus_register_device(). This is not the probe function for the device, and thus there is no code to trigger the release of the resource on unregistration.
Moreover, when the mdiodev is eventually probed, if the driver fails or the driver is unbound, the GPIO will be released, but a reference will be left behind.
Using devm* with a struct device that is *not* currently being probed is fundamentally wrong - an abuse of devm.
---
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
CC: [email protected]
--- drivers/net/phy/mdio_bus.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/phy/mdio_bus.c +2 -2
@@ -36,8 +36,8 @@static int mdiobus_register_gpiod (struct mdio_device *mdiodev) {/* Deassert the optional reset signal */ - mdiodev->reset_gpio =devm_gpiod_get_optional (&mdiodev->dev, -"reset" ,GPIOD_OUT_LOW ); + mdiodev->reset_gpio =gpiod_get_optional (&mdiodev->dev, +"reset" ,GPIOD_OUT_LOW );if (IS_ERR (mdiodev->reset_gpio))return PTR_ERR (mdiodev->reset_gpio);
Signature · 1 line
2.50.1
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Fri, 1 Aug 2025 14:27:42 -0700 you wrote:
This reverts commit
3b98c9352511db627b606477fc7944b2fa53a165.Russell says:
Using devm_*() [here] is completely wrong, because this is called from
mdiobus_register_device(). This is not the probe function for the device, and thus there is no code to trigger the release of the resource on unregistration.[...]
Here is the summary with links:
- [net] Revert "net: mdio_bus: Use devm for getting reset GPIO"
https://git.kernel.org/netdev/net/c/175811b8f05f
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html