* [PATCH v2] rtc: stm32: fix clock leak on pinctrl probe failure
@ 2026-09-18 9:58 Cong Nguyen
0 siblings, 0 replies; only message in thread
From: Cong Nguyen @ 2026-09-18 9:58 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Maxime Coquelin, Alexandre Torgue, Valentin Caron, Linus Walleij,
Antonio Borneo, linux-rtc, linux-stm32, linux-arm-kernel,
linux-kernel
A failing devm_pinctrl_register_and_init() or pinctrl_enable() in
stm32_rtc_probe() returns directly instead of going through err:,
leaking rtc_ck/pclk -- and since -EPROBE_DEFER is routine here, each
deferred retry leaks another.
Route both through err:, and move the pinctrl setup earlier (right
after stm32_rtc_init(), before the RTC device/IRQ are registered) so
disabling the clocks there doesn't race a still-live IRQ.
Fixes: 16ad2bc09efb ("rtc: stm32: add pinctrl and pinmux interfaces")
Reported-by: Sashiko AI review <sashiko-bot@kernel.org>
Link: https://lore.kernel.org/r/20260914135401.373D91F000FF@smtp.kernel.org
Assisted-by: LLM
Signed-off-by: Cong Nguyen <congnt264@gmail.com>
---
Changes in v2:
- Sashiko found that routing the pinctrl failures through err: (as v1
did) disables the clocks while the still-registered RTC device and
alarm IRQ are live. Moved the pinctrl setup earlier instead of just
moving where the leak was plugged.
drivers/rtc/rtc-stm32.c | 24 ++++++++++++++----------
1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/drivers/rtc/rtc-stm32.c b/drivers/rtc/rtc-stm32.c
index d4ebf3eb54aa..457f66663ba5 100644
--- a/drivers/rtc/rtc-stm32.c
+++ b/drivers/rtc/rtc-stm32.c
@@ -1137,6 +1137,20 @@ static int stm32_rtc_probe(struct platform_device *pdev)
if (ret)
goto err;
+ stm32_rtc_clean_outs(rtc);
+
+ ret = devm_pinctrl_register_and_init(&pdev->dev, &stm32_rtc_pdesc, rtc, &pctl);
+ if (ret) {
+ dev_err_probe(&pdev->dev, ret, "pinctrl register failed");
+ goto err;
+ }
+
+ ret = pinctrl_enable(pctl);
+ if (ret) {
+ dev_err_probe(&pdev->dev, ret, "pinctrl enable failed");
+ goto err;
+ }
+
rtc->irq_alarm = platform_get_irq(pdev, 0);
if (rtc->irq_alarm <= 0) {
ret = rtc->irq_alarm;
@@ -1172,16 +1186,6 @@ static int stm32_rtc_probe(struct platform_device *pdev)
goto err;
}
- stm32_rtc_clean_outs(rtc);
-
- ret = devm_pinctrl_register_and_init(&pdev->dev, &stm32_rtc_pdesc, rtc, &pctl);
- if (ret)
- return dev_err_probe(&pdev->dev, ret, "pinctrl register failed");
-
- ret = pinctrl_enable(pctl);
- if (ret)
- return dev_err_probe(&pdev->dev, ret, "pinctrl enable failed");
-
/*
* If INITS flag is reset (calendar year field set to 0x00), calendar
* must be initialized
--
2.25.1
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-18 9:59 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-18 9:58 [PATCH v2] rtc: stm32: fix clock leak on pinctrl probe failure Cong Nguyen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®