From c60478875a445dee1206aad6285c18cd8c91f7f2 Mon Sep 17 00:00:00 2001 From: Liu Dalin Date: Thu, 27 Aug 2026 16:03:18 +0800 Subject: [PATCH] rtc: ftrtc010: fix clock resource leak on probe failure 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 Reviewed-by: Linus Walleij Tested-by: Liu Dalin Link: https://patch.msgid.link/AC51B5F2C5FFEBB0+20260827080320.3351155-2-liudalin@kylinsec.com.cn Signed-off-by: Alexandre Belloni --- 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);