Re: [PATCH v2] net: mdio: airoha: fix reset control leak in error path
From: Larysa Zaremba
Date: Thu Jun 25 2026 - 06:11:19 EST
Please, specify the target tree (probably, net) via a subject prefix.
Also, looks like you are missing to many CCs [0]
[0]
https://netdev-ctrl.bots.linux.dev/logs/build/1114710/14639274/cc_maintainers/summary
On Mon, Jun 22, 2026 at 07:54:03PM +0800, 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.
>
Sashiko correctly points out that since the reset controller is exclusive,
there is no refcount leak. [1]
So the problem is missing rstc->rcdev->ops->assert(rstc->rcdev, rstc->id) call.
It would be great if you could describe, what problem this can cause.
> 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().
Sashiko correctly points out you do not actually do this, which is fine, just
update the commit message. [1]
[1] https://sashiko.dev/#/patchset/20260622115403.39772-1-vulab%40iscas.ac.cn
> Fixes: 67e3ba978361 ("net: mdio: Add MDIO bus controller for Airoha AN7583")
> Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
> ---
> 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)
>
>