[PATCH] thermal: ti-soc-thermal: Check return value of clk_prepare_enable()
From: Жамбакиев Радий Рикардинович
Date: Fri Sep 11 2026 - 05:47:23 EST
From: Radiy Zhambakiev <r.zhambakiev@xxxxxxxxxxxxxxxxx>
On SoCs with the CLK_CTRL feature the bandgap fclk is enabled in
ti_bandgap_probe(), but the return value of clk_prepare_enable() is
ignored. If the clock cannot be enabled, probe continues and all
subsequent register accesses fail or return stale values.
Check the return value and abort probe with the proper error code,
using the existing put_clks cleanup path, which releases both clocks
and the TSHUT IRQ that have been acquired at that point.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 8feaf0ce1a04 ("staging: OMAP4+: thermal: introduce bandgap temperature sensor")
Signed-off-by: Radiy Zhambakiev <r.zhambakiev@xxxxxxxxxxxxxxxxx>
---
drivers/thermal/ti-soc-thermal/ti-bandgap.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
diff --git a/drivers/thermal/ti-soc-thermal/ti-bandgap.c b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
index ba43399d0b38..de9ad65d854a 100644
--- a/drivers/thermal/ti-soc-thermal/ti-bandgap.c
+++ b/drivers/thermal/ti-soc-thermal/ti-bandgap.c
@@ -953,9 +953,13 @@ int ti_bandgap_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Cannot re-set clock rate. Continuing\n");
bgp->clk_rate = clk_rate;
- if (TI_BANDGAP_HAS(bgp, CLK_CTRL))
- clk_prepare_enable(bgp->fclock);
-
+ if (TI_BANDGAP_HAS(bgp, CLK_CTRL)) {
+ ret = clk_prepare_enable(bgp->fclock);
+ if (ret) {
+ dev_err(&pdev->dev, "failed to enable fclock\n");
+ goto put_clks;
+ }
+ }
spin_lock_init(&bgp->lock);
bgp->dev = &pdev->dev;
--
2.53.0