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. Fix this by reorganizing the error handling to use a goto label, ensuring reset_control_assert() is called on all error paths before returning. Also add error checking for reset_control_deassert(). Fixes: 67e3ba978361 ("net: mdio: Add MDIO bus controller for Airoha AN7583") Signed-off-by: Wentao Liang --- drivers/net/mdio/mdio-airoha.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/net/mdio/mdio-airoha.c b/drivers/net/mdio/mdio-airoha.c index 52e7475121ea..4c1b2415687c 100644 --- a/drivers/net/mdio/mdio-airoha.c +++ b/drivers/net/mdio/mdio-airoha.c @@ -246,15 +246,17 @@ static int airoha_mdio_probe(struct platform_device *pdev) ret = clk_set_rate(priv->clk, freq); if (ret) - return ret; + goto err_reset_assert; ret = devm_of_mdiobus_register(dev, bus, dev->of_node); - if (ret) { - reset_control_assert(priv->reset); - return ret; - } + if (ret) + goto err_reset_assert; return 0; + +err_reset_assert: + reset_control_assert(priv->reset); + return ret; } static const struct of_device_id airoha_mdio_dt_ids[] = { -- 2.39.5 (Apple Git-154)