Re: [PATCH] fix: net: marvell: orion_mdio_probe: fix clock reference leak on extra clock detection

From: WenTao Liang

Date: Sun Jun 28 2026 - 00:05:25 EST




> 2026年6月26日 23:19,WenTao Liang <vulab@xxxxxxxxxxx> 写道:
>
> The code calls of_clk_get(pdev->dev.of_node, ARRAY_SIZE(dev->clk)) to
> detect unsupported extra clocks. If an extra clock exists, the function
> prints a warning but discards the returned clk pointer without calling
> clk_put, leaking a clock reference on every probe.
>
> Store the returned clock and call clk_put after the warning to properly
> release the acquired reference.
>
> Cc: stable@xxxxxxxxxxxxxxx
> Fixes: ea664b1bdc19 ("net: mvmdio: print warning when orion-mdio has too many clocks")
> Signed-off-by: WenTao Liang <vulab@xxxxxxxxxxx>
> ---
> drivers/net/ethernet/marvell/mvmdio.c | 17 ++++++++++++-----
> 1 file changed, 12 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/net/ethernet/marvell/mvmdio.c b/drivers/net/ethernet/marvell/mvmdio.c
> index 3f4447e68888..4e5b5c5f7301 100644
> --- a/drivers/net/ethernet/marvell/mvmdio.c
> +++ b/drivers/net/ethernet/marvell/mvmdio.c
> @@ -339,11 +339,18 @@ static int orion_mdio_probe(struct platform_device *pdev)
> clk_prepare_enable(dev->clk[i]);
> }
>
> - if (!IS_ERR(of_clk_get(pdev->dev.of_node,
> - ARRAY_SIZE(dev->clk))))
> - dev_warn(&pdev->dev,
> - "unsupported number of clocks, limiting to the first "
> - __stringify(ARRAY_SIZE(dev->clk)) "\n");
> + {
> + struct clk *extra_clk;
> +
> + extra_clk = of_clk_get(pdev->dev.of_node,
> + ARRAY_SIZE(dev->clk));
> + if (!IS_ERR(extra_clk)) {
> + dev_warn(&pdev->dev,
> + "unsupported number of clocks, limiting to the first "
> + __stringify(ARRAY_SIZE(dev->clk)) "\n");
> + clk_put(extra_clk);
> + }
> + }
>
> if (type == BUS_TYPE_XSMI)
> orion_mdio_xsmi_set_mdc_freq(bus);
> --
> 2.39.5 (Apple Git-154)

Please ignore this patch. I will resend a proper version after
learning the kernel submission process.

Apologies for the noise.

Best regards,
WenTao Liang