Linux RTC
 help / color / mirror / Atom feed
* [PATCH] rtc: ma35d1: release the clock reference on probe failure
@ 2026-11-04  2:53 Wentao Liang
  2026-11-04  3:00 ` sashiko-bot
  2026-11-04  7:10 ` Krzysztof Kozlowski
  0 siblings, 2 replies; 3+ messages in thread
From: Wentao Liang @ 2026-11-04  2:53 UTC (permalink / raw)
  To: Jacky Huang, Shan-Chun Hung, Alexandre Belloni
  Cc: linux-arm-kernel, linux-rtc

ma35d1_rtc_probe() gets the RTC clock with of_clk_get() and enables it
with clk_prepare_enable(). The clock reference is never dropped and the
clock is never disabled, not on the many later error returns and not on
success either, since the driver has no remove callback. The reference
and the enabled clock are leaked for every probe attempt.

Use devm_clk_get_enabled(), which ties both the reference and the
enabled state to the device lifetime.

Fixes: dc0684adf3b6 ("rtc: Add driver for Nuvoton ma35d1 rtc controller")
Cc: stable@vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/rtc/rtc-ma35d1.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/rtc/rtc-ma35d1.c b/drivers/rtc/rtc-ma35d1.c
index cfcfc28060f6..43358d68565a 100644
--- a/drivers/rtc/rtc-ma35d1.c
+++ b/drivers/rtc/rtc-ma35d1.c
@@ -221,14 +221,10 @@ static int ma35d1_rtc_probe(struct platform_device *pdev)
 	if (IS_ERR(rtc->rtc_reg))
 		return PTR_ERR(rtc->rtc_reg);
 
-	clk = of_clk_get(pdev->dev.of_node, 0);
+	clk = devm_clk_get_enabled(&pdev->dev, NULL);
 	if (IS_ERR(clk))
 		return dev_err_probe(&pdev->dev, PTR_ERR(clk), "failed to find rtc clock\n");
 
-	ret = clk_prepare_enable(clk);
-	if (ret)
-		return ret;
-
 	if (!(rtc_reg_read(rtc, MA35_REG_RTC_INIT) & RTC_INIT_ACTIVE)) {
 		ret = ma35d1_rtc_init(rtc, RTC_INIT_TIMEOUT);
 		if (ret)
-- 
2.34.1


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

end of thread, other threads:[~2026-11-04  7:10 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-04  2:53 [PATCH] rtc: ma35d1: release the clock reference on probe failure Wentao Liang
2026-11-04  3:00 ` sashiko-bot
2026-11-04  7:10 ` Krzysztof Kozlowski

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