* [PATCH net] net: mdio: fix resource leak in mdiobus_register_device()
@ 2025-11-08 6:49 Buday Csaba
2025-11-11 2:30 ` patchwork-bot+netdevbpf
0 siblings, 1 reply; 2+ messages in thread
From: Buday Csaba @ 2025-11-08 6:49 UTC (permalink / raw)
To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
Eric Dumazet, Jakub Kicinski, Paolo Abeni, David Bauer, netdev,
linux-kernel
Cc: Buday Csaba
Fix a possible leak in mdiobus_register_device() when both a
reset-gpio and a reset-controller are present.
Clean up the already claimed reset-gpio, when the registration of
the reset-controller fails, so when an error code is returned, the
device retains its state before the registration attempt.
Link: https://lore.kernel.org/all/20251106144603.39053c81@kernel.org/
Fixes: 71dd6c0dff51 ("net: phy: add support for reset-controller")
Signed-off-by: Buday Csaba <buday.csaba@prolan.hu>
---
drivers/net/phy/mdio_bus.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index cad6ed3aa10b..4354241137d5 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -73,8 +73,11 @@ int mdiobus_register_device(struct mdio_device *mdiodev)
return err;
err = mdiobus_register_reset(mdiodev);
- if (err)
+ if (err) {
+ gpiod_put(mdiodev->reset_gpio);
+ mdiodev->reset_gpio = NULL;
return err;
+ }
/* Assert the reset signal */
mdio_device_reset(mdiodev, 1);
base-commit: 96a9178a29a6b84bb632ebeb4e84cf61191c73d5
--
2.39.5
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [PATCH net] net: mdio: fix resource leak in mdiobus_register_device()
2025-11-08 6:49 [PATCH net] net: mdio: fix resource leak in mdiobus_register_device() Buday Csaba
@ 2025-11-11 2:30 ` patchwork-bot+netdevbpf
0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-11-11 2:30 UTC (permalink / raw)
To: Buday Csaba
Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni, mail,
netdev, linux-kernel
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Sat, 8 Nov 2025 07:49:22 +0100 you wrote:
> Fix a possible leak in mdiobus_register_device() when both a
> reset-gpio and a reset-controller are present.
> Clean up the already claimed reset-gpio, when the registration of
> the reset-controller fails, so when an error code is returned, the
> device retains its state before the registration attempt.
>
> Link: https://lore.kernel.org/all/20251106144603.39053c81@kernel.org/
> Fixes: 71dd6c0dff51 ("net: phy: add support for reset-controller")
> Signed-off-by: Buday Csaba <buday.csaba@prolan.hu>
>
> [...]
Here is the summary with links:
- [net] net: mdio: fix resource leak in mdiobus_register_device()
https://git.kernel.org/netdev/net/c/e6ca8f533ed4
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-11 2:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-08 6:49 [PATCH net] net: mdio: fix resource leak in mdiobus_register_device() Buday Csaba
2025-11-11 2:30 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox