[PATCH] rtc: ma35d1: release the clock reference on probe failure
Wentao Liang
vulab at iscas.ac.cn
Tue Nov 3 18:53:39 PST 2026
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 at vger.kernel.org
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <vulab at 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
More information about the linux-arm-kernel
mailing list