[PATCH] soc: imx8m: drop the clock reference if enabling it fails
Wentao Liang
vulab at iscas.ac.cn
Tue Nov 3 18:14:29 PST 2026
imx8m_soc_prepare() gets the OCOTP clock with of_clk_get_by_name() and
releases the register mapping when clk_prepare_enable() fails, but the
clock reference itself is left behind. imx8m_soc_unprepare() only runs
on the success path of imx8m_soc_probe(), so the reference is never
dropped when the clock cannot be enabled.
Put the clock before jumping to the error label.
Fixes: f6ef3d9ff812 ("soc: imx8m: Fix error handling for clk_prepare_enable()")
Cc: stable at vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab at iscas.ac.cn>
---
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..70b281927c4b 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
More information about the linux-arm-kernel
mailing list