Skip to contentSkip to conversation

Revert "net: mdio_bus: Use devm for getting reset GPIO"

PATCH Applied Jakub Kicinski 2 participants 2 messages Aug 1, 2025 – Aug 5, 2025

Subsystems (3)
lore
Share & tools
lore

Jakub Kicinski

author maintainer
#0 lore raw

PATCH 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.

Fixes 3b98c9352511 ("net: mdio_bus: Use devm for getting reset GPIO")

---
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
index 24bdab5bdd24..fda2e27c1810 100644
@@ -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
#1 lore raw
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