RE: [PATCH] soc: imx8m: fix clock reference leak in imx8m_soc_prepare()
From: Peng Fan (OSS)
Date: Mon Jun 29 2026 - 03:27:15 EST
> Subject: [PATCH] soc: imx8m: fix clock reference leak in
> imx8m_soc_prepare()
>
> When clk_prepare_enable() fails, the error path does not release the
> clock reference obtained by of_clk_get_by_name(). Add clk_put() to
> the error path before iounmap().
>
> Fixes: 390c01073f5d ("soc: imx8m: Cleanup with adding
> imx8m_soc_[un]prepare")
> Signed-off-by: Felix Gu <ustc.gu@xxxxxxxxx>
> ---
> drivers/soc/imx/soc-imx8m.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/soc/imx/soc-imx8m.c b/drivers/soc/imx/soc-
> imx8m.c index fc080e56f50d..de19972435f9 100644
> --- a/drivers/soc/imx/soc-imx8m.c
> +++ b/drivers/soc/imx/soc-imx8m.c
> @@ -150,10 +150,12 @@ static int imx8m_soc_prepare(struct
> platform_device *pdev, const char *ocotp_com
>
> ret = clk_prepare_enable(drvdata->clk);
> if (ret)
> - goto err_clk;
> + goto put_clk;
>
> return 0;
>
> +put_clk:
> + clk_put(drvdata->clk);
> err_clk:
It should be safe to directly put "clk_put" here, no
need extra label.
Regards
Peng.
> iounmap(drvdata->ocotp_base);
> return ret;
>
> ---
> base-commit: 30ffa8de54e5cc80d93fd211ca134d1764a7011f
> change-id: 20260626-soc-imx8m-938e89104044
>
> Best regards,
> --
> Felix Gu <ustc.gu@xxxxxxxxx>