Linux RTC
 help / color / mirror / Atom feed
* [PATCH] rtc: ftrtc010: fix clock resource leak on probe failure
@ 2026-08-27  1:57 Liu Dalin
  2026-08-27  2:10 ` sashiko-bot
  0 siblings, 1 reply; 19+ messages in thread
From: Liu Dalin @ 2026-08-27  1:57 UTC (permalink / raw)
  To: Hans Ulli Kroll, Linus Walleij, Alexandre Belloni
  Cc: linux-arm-kernel, linux-rtc, linux-kernel, Liu Dalin,
	Deng Yingchao, Qin Yungao, Luo Qiu

When devm_rtc_register_device() fails, ftrtc010_rtc_probe() returns
the error directly without releasing clocks obtained via
clk_prepare_enable(). This leaks both extclk and pclk resources,
which may prevent subsequent probe attempts or module removal.

Capture the return value and jump to the error handling path to
properly release clocks via clk_disable_unprepare().

Fixes smatch warnings:
- drivers/rtc/rtc-ftrtc010.c:189 ftrtc010_rtc_probe() warn:
  'rtc->extclk' from clk_prepare_enable() not released on lines: 183.
- drivers/rtc/rtc-ftrtc010.c:189 ftrtc010_rtc_probe() warn:
  'rtc->pclk' from clk_prepare_enable() not released on lines: 183.

Fixes: fdcfd854333b ("rtc: rework rtc_register_device() resource management")
Assisted-by: smatch:2.0 [static analysis]
Signed-off-by: Liu Dalin <liudalin@kylinsec.com.cn>
---
 drivers/rtc/rtc-ftrtc010.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/rtc/rtc-ftrtc010.c b/drivers/rtc/rtc-ftrtc010.c
index 98fa0f518303..512790bc3f2b 100644
--- a/drivers/rtc/rtc-ftrtc010.c
+++ b/drivers/rtc/rtc-ftrtc010.c
@@ -180,7 +180,11 @@ static int ftrtc010_rtc_probe(struct platform_device *pdev)
 	if (unlikely(ret))
 		goto err_disable_extclk;
 
-	return devm_rtc_register_device(rtc_dev);
+	ret = devm_rtc_register_device(rtc_dev);
+	if (ret)
+		goto err_disable_extclk;
+
+	return 0;
 
 err_disable_extclk:
 	clk_disable_unprepare(rtc->extclk);
-- 
2.43.0


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

end of thread, other threads:[~2026-08-27  8:17 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-27  1:57 [PATCH] rtc: ftrtc010: fix clock resource leak on probe failure Liu Dalin
2026-08-27  2:10 ` sashiko-bot
2026-08-27  6:30   ` [PATCH v1 0/3] rtc: ftrtc010: fix resource management and integer overflow Liu Dalin
     [not found]   ` <20260827063019.3342085-1-liudalin@kylinsec.com.cn>
2026-08-27  6:30     ` [PATCH v1 1/3] rtc: ftrtc010: fix clock resource leak on probe failure Liu Dalin
2026-08-27  6:45       ` sashiko-bot
2026-08-27  8:05         ` liudalin
2026-08-27  6:30     ` [PATCH v1 2/3] rtc: ftrtc010: use devm clock APIs to fix use-after-disable in remove Liu Dalin
2026-08-27  6:43       ` sashiko-bot
2026-08-27  8:06         ` liudalin
2026-08-27  6:30     ` [PATCH v1 3/3] rtc: ftrtc010: fix integer overflow in time calculation Liu Dalin
2026-08-27  6:53       ` sashiko-bot
2026-08-27  8:07         ` liudalin
2026-08-27  8:03   ` [PATCH v2 0/3] rtc: ftrtc010: fix resource management and integer overflow Liu Dalin
     [not found]   ` <20260827080320.3351155-1-liudalin@kylinsec.com.cn>
2026-08-27  8:03     ` [PATCH v2 1/3] rtc: ftrtc010: fix clock resource leak on probe failure Liu Dalin
2026-08-27  8:15       ` sashiko-bot
2026-08-27  8:03     ` [PATCH v2 2/3] rtc: ftrtc010: use devm clock APIs to fix use-after-disable in remove Liu Dalin
2026-08-27  8:15       ` sashiko-bot
2026-08-27  8:03     ` [PATCH v2 3/3] rtc: ftrtc010: fix integer overflow in time calculation Liu Dalin
2026-08-27  8:17       ` sashiko-bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox