mirror of
https://github.com/raspberrypi/linux.git
synced 2025-12-06 01:49:46 +00:00
net: mdio: fix resource leak in mdiobus_register_device()
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: 71dd6c0dff ("net: phy: add support for reset-controller")
Signed-off-by: Buday Csaba <buday.csaba@prolan.hu>
Link: https://patch.msgid.link/4b419377f8dd7d2f63f919d0f74a336c734f8fff.1762584481.git.buday.csaba@prolan.hu
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
This commit is contained in:
committed by
Jakub Kicinski
parent
0725e6afb5
commit
e6ca8f533e
@@ -73,8 +73,11 @@ int mdiobus_register_device(struct mdio_device *mdiodev)
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
err = mdiobus_register_reset(mdiodev);
|
err = mdiobus_register_reset(mdiodev);
|
||||||
if (err)
|
if (err) {
|
||||||
|
gpiod_put(mdiodev->reset_gpio);
|
||||||
|
mdiodev->reset_gpio = NULL;
|
||||||
return err;
|
return err;
|
||||||
|
}
|
||||||
|
|
||||||
/* Assert the reset signal */
|
/* Assert the reset signal */
|
||||||
mdio_device_reset(mdiodev, 1);
|
mdio_device_reset(mdiodev, 1);
|
||||||
|
|||||||
Reference in New Issue
Block a user