[PATCH] clk: palmas: unprepare clock on provider registration failure
From: Myeonghun Pak
Date: Tue Jun 23 2026 - 05:08:50 EST
palmas_clks_init_configure() prepares the clock when an external control
pin is configured. If the subsequent of_clk_add_hw_provider() call fails,
palmas_clks_probe() returns the error without dropping that prepare
reference.
Unprepare the clock on that error path when external control is active, so
the probe failure path balances the successful clk_prepare().
This issue was identified during our ongoing static-analysis research while
reviewing kernel code.
Fixes: 942d1d674931 ("clk: Add driver for Palmas clk32kg and clk32kgaudio clocks")
Co-developed-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Ijae Kim <ae878000@xxxxxxxxx>
Signed-off-by: Myeonghun Pak <mhun512@xxxxxxxxx>
---
drivers/clk/clk-palmas.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/clk/clk-palmas.c b/drivers/clk/clk-palmas.c
index 39049f62db..ab9df2eedb 100644
--- a/drivers/clk/clk-palmas.c
+++ b/drivers/clk/clk-palmas.c
@@ -265,8 +265,11 @@ static int palmas_clks_probe(struct platform_device *pdev)
}
ret = of_clk_add_hw_provider(node, of_clk_hw_simple_get, &cinfo->hw);
- if (ret < 0)
+ if (ret < 0) {
dev_err(&pdev->dev, "Fail to add clock driver, %d\n", ret);
+ if (cinfo->ext_control_pin)
+ clk_unprepare(cinfo->hw.clk);
+ }
return ret;
}
--
2.47.1