All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] rtc: omap: check clk_prepare_enable() return value
@ 2026-09-11 11:44 Жамбакиев Радий Рикардинович
  2026-09-11 11:56 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Жамбакиев Радий Рикардинович @ 2026-09-11 11:44 UTC (permalink / raw)
  To: Alexandre Belloni
  Cc: Жамбакиев Радий Рикардинович,
	Tony Lindgren, Keerthy, linux-rtc@vger.kernel.org,
	linux-kernel@vger.kernel.org, lvc-project@linuxtesting.org

From: Radiy Zhambakiev <r.zhambakiev@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@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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-11 11:56 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-11 11:44 [PATCH] rtc: omap: check clk_prepare_enable() return value Жамбакиев Радий Рикардинович
2026-09-11 11:56 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.