mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] mdio-airoha: fix refcount leak in airoha_mdio_probe()
@ 2026-06-09  9:07 Wentao Liang
  2026-06-09  9:47 ` Andrew Lunn
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-06-09  9:07 UTC (permalink / raw)
  To: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni
  Cc: netdev, linux-kernel, Wentao Liang, stable

In airoha_mdio_probe(), after calling reset_control_deassert(),
if clk_set_rate() fails, the function returns immediately without
calling reset_control_assert().  This leaves the reset line
deasserted and causes a reference count leak on shared reset
controllers.  The devm cleanup does not assert the reset line, so
the unbalanced deassert persists.

Fix this by adding a reset_control_assert() call on the
clk_set_rate() error path, matching the existing error handling
for devm_of_mdiobus_register().

Cc: stable@vger.kernel.org
Fixes: 67e3ba978361 ("net: mdio: Add MDIO bus controller for Airoha AN7583")
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/net/mdio/mdio-airoha.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mdio/mdio-airoha.c b/drivers/net/mdio/mdio-airoha.c
index 52e7475121ea..030482b8318f 100644
--- a/drivers/net/mdio/mdio-airoha.c
+++ b/drivers/net/mdio/mdio-airoha.c
@@ -245,8 +245,10 @@ static int airoha_mdio_probe(struct platform_device *pdev)
 		freq = 2500000;
 
 	ret = clk_set_rate(priv->clk, freq);
-	if (ret)
+	if (ret) {
+		reset_control_assert(priv->reset);
 		return ret;
+	}
 
 	ret = devm_of_mdiobus_register(dev, bus, dev->of_node);
 	if (ret) {
-- 
2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH] mdio-airoha: fix refcount leak in airoha_mdio_probe()
  2026-06-09  9:07 [PATCH] mdio-airoha: fix refcount leak in airoha_mdio_probe() Wentao Liang
@ 2026-06-09  9:47 ` Andrew Lunn
  0 siblings, 0 replies; 2+ messages in thread
From: Andrew Lunn @ 2026-06-09  9:47 UTC (permalink / raw)
  To: Wentao Liang
  Cc: hkallweit1, linux, davem, edumazet, kuba, pabeni, netdev,
	linux-kernel, stable

On Tue, Jun 09, 2026 at 09:07:29AM +0000, Wentao Liang wrote:
> In airoha_mdio_probe(), after calling reset_control_deassert(),
> if clk_set_rate() fails, the function returns immediately without
> calling reset_control_assert().  This leaves the reset line
> deasserted and causes a reference count leak on shared reset
> controllers.  The devm cleanup does not assert the reset line, so
> the unbalanced deassert persists.
> 
> Fix this by adding a reset_control_assert() call on the
> clk_set_rate() error path, matching the existing error handling
> for devm_of_mdiobus_register().
> 
> Cc: stable@vger.kernel.org
> Fixes: 67e3ba978361 ("net: mdio: Add MDIO bus controller for Airoha AN7583")
> Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
> ---
>  drivers/net/mdio/mdio-airoha.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/mdio/mdio-airoha.c b/drivers/net/mdio/mdio-airoha.c
> index 52e7475121ea..030482b8318f 100644
> --- a/drivers/net/mdio/mdio-airoha.c
> +++ b/drivers/net/mdio/mdio-airoha.c
> @@ -245,8 +245,10 @@ static int airoha_mdio_probe(struct platform_device *pdev)
>  		freq = 2500000;
>  
>  	ret = clk_set_rate(priv->clk, freq);
> -	if (ret)
> +	if (ret) {
> +		reset_control_assert(priv->reset);
>  		return ret;
> +	}
>  
>  	ret = devm_of_mdiobus_register(dev, bus, dev->of_node);
>  	if (ret) {

devm_of_mdiobus_register() also calls reset_control_assert() on
error. So please put all the error cleanup handling at the end and use
goto.

    Andrew

---
pw-bot: cr

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-06-09  9:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-09  9:07 [PATCH] mdio-airoha: fix refcount leak in airoha_mdio_probe() Wentao Liang
2026-06-09  9:47 ` Andrew Lunn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®