[PATCH] soc: imx8m: Fix clock leak in imx8m_soc_prepare()
From: Wentao Liang
Date: Thu Sep 17 2026 - 12:21:27 EST
When clk_prepare_enable() fails, imx8m_soc_prepare() jumps to err_clk,
which only undoes the iounmap. The reference obtained by
of_clk_get_by_name() is not dropped, and imx8m_soc_probe() returns the
error without calling imx8m_soc_unprepare(), so the clock reference is
leaked.
Release it before leaving the prepare function.
Fixes: 390c01073f5d ("soc: imx8m: Cleanup with adding imx8m_soc_[un]prepare")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Wentao Liang <vulab@xxxxxxxxxxx>
---
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 77763a107edb..f4c2d5e37ec7 100644
--- a/drivers/soc/imx/soc-imx8m.c
+++ b/drivers/soc/imx/soc-imx8m.c
@@ -149,8 +149,10 @@ static int imx8m_soc_prepare(struct platform_device *pdev, const char *ocotp_com
}
ret = clk_prepare_enable(drvdata->clk);
- if (ret)
+ if (ret) {
+ clk_put(drvdata->clk);
goto err_clk;
+ }
return 0;
--
2.34.1