lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <20250807135449.254254-2-csokas.bence@prolan.hu>
Date: Thu, 7 Aug 2025 15:54:49 +0200
From: Bence Csókás <csokas.bence@...lan.hu>
To: Rob Herring <robh@...nel.org>, Geert Uytterhoeven
	<geert+renesas@...der.be>, "David S. Miller" <davem@...emloft.net>, "Sergei
 Shtylyov" <sergei.shtylyov@...entembedded.com>, <netdev@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>
CC: Buday Csaba <buday.csaba@...lan.hu>, Andrew Lunn <andrew@...n.ch>,
	Csókás Bence <csokas.bence@...lan.hu>, "Heiner
 Kallweit" <hkallweit1@...il.com>, Russell King <linux@...linux.org.uk>, "Eric
 Dumazet" <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>, Paolo Abeni
	<pabeni@...hat.com>
Subject: [PATCH net v2] net: mdiobus: release reset_gpio in mdiobus_unregister_device()

From: Buday Csaba <buday.csaba@...lan.hu>

reset_gpio is claimed in mdiobus_register_device(), but it is not
released in mdiobus_unregister_device(). It is instead only
released when the whole MDIO bus is unregistered.
When a device uses the reset_gpio property, it becomes impossible
to unregister it and register it again, because the GPIO remains
claimed.
This patch resolves that issue.

Fixes: bafbdd527d56 ("phylib: Add device reset GPIO support") # see notes
Reviewed-by: Andrew Lunn <andrew@...n.ch>
Cc: Csókás Bence <csokas.bence@...lan.hu>
[ csokas.bence: Resolve rebase conflict and clarify msg ]
Signed-off-by: Buday Csaba <buday.csaba@...lan.hu>
---

Notes:
    Changes in v2:
    * Rebase onto net-next (from 6.12)
    * Clarify msg after talking with Csaba in person
    * Collect Andrew's tag
    
    Link to v1:
    https://lore.kernel.org/all/20250709133222.48802-3-buday.csaba@prolan.hu/
    
    Note to stable@:
    * for 6.12 and before, the above v1 patch can be used.

 drivers/net/phy/mdio_bus.c          | 1 +
 drivers/net/phy/mdio_bus_provider.c | 3 ---
 2 files changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/net/phy/mdio_bus.c b/drivers/net/phy/mdio_bus.c
index fda2e27c1810..cad6ed3aa10b 100644
--- a/drivers/net/phy/mdio_bus.c
+++ b/drivers/net/phy/mdio_bus.c
@@ -91,6 +91,7 @@ int mdiobus_unregister_device(struct mdio_device *mdiodev)
 	if (mdiodev->bus->mdio_map[mdiodev->addr] != mdiodev)
 		return -EINVAL;
 
+	gpiod_put(mdiodev->reset_gpio);
 	reset_control_put(mdiodev->reset_ctrl);
 
 	mdiodev->bus->mdio_map[mdiodev->addr] = NULL;
diff --git a/drivers/net/phy/mdio_bus_provider.c b/drivers/net/phy/mdio_bus_provider.c
index 48dc4bf85125..f43973e73ea3 100644
--- a/drivers/net/phy/mdio_bus_provider.c
+++ b/drivers/net/phy/mdio_bus_provider.c
@@ -443,9 +443,6 @@ void mdiobus_unregister(struct mii_bus *bus)
 		if (!mdiodev)
 			continue;
 
-		if (mdiodev->reset_gpio)
-			gpiod_put(mdiodev->reset_gpio);
-
 		mdiodev->device_remove(mdiodev);
 		mdiodev->device_free(mdiodev);
 	}

base-commit: d9104cec3e8fe4b458b74709853231385779001f
-- 
2.43.0



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ