[lvc-project] [PATCH] rtc: omap: check clk_prepare_enable() return value

Жамбакиев Радий Рикардинович r.zhambakiev at prosoftsystems.ru
Fri Sep 11 14:44:18 MSK 2026


From: Radiy Zhambakiev <r.zhambakiev at prosoftsystems.ru>

clk_prepare_enable() may fail, e.g. with -EPROBE_DEFER if the clock
provider is not ready yet. The return value is ignored in
omap_rtc_probe(), so the driver continues probing with an unprepared
clock and later calls clk_disable_unprepare() on it, in
omap_rtc_remove() or in the ioremap error path, leading to a
prepare/unprepare imbalance.

Check the return value and propagate the error on failure. No
explicit cleanup is needed on the error path as the clock reference
is managed by devres and the clock was never prepared.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 532409aa1ba8 ("rtc: omap: Add internal clock enabling support")
Signed-off-by: Radiy Zhambakiev <r.zhambakiev at prosoftsystems.ru>
---
 drivers/rtc/rtc-omap.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c
index 0f90065e352c..97d03ded51db 100644
--- a/drivers/rtc/rtc-omap.c
+++ b/drivers/rtc/rtc-omap.c
@@ -758,8 +758,11 @@ static int omap_rtc_probe(struct platform_device *pdev)
 	else
 		rtc->clk = devm_clk_get(&pdev->dev, "int-clk");
 
-	if (!IS_ERR(rtc->clk))
-		clk_prepare_enable(rtc->clk);
+	if (!IS_ERR(rtc->clk)) {
+		ret = clk_prepare_enable(rtc->clk);
+		if (ret)
+			return ret;
+	}
 
 	rtc->base = devm_platform_ioremap_resource(pdev, 0);
 	if (IS_ERR(rtc->base)) {
-- 
2.53.0



More information about the lvc-project mailing list