* [PATCH] watchdog: stm32_iwdg: use managed variant of dev_pm_set_wake_irq()
@ 2026-11-16 19:01 Antonio Borneo
2026-11-16 19:09 ` sashiko-bot
2026-11-16 20:36 ` Guenter Roeck
0 siblings, 2 replies; 3+ messages in thread
From: Antonio Borneo @ 2026-11-16 19:01 UTC (permalink / raw)
To: Wim Van Sebroeck, Guenter Roeck, Maxime Coquelin,
Alexandre Torgue, Clément Le Goffic, Marek Vasut
Cc: Antonio Borneo, linux-watchdog, linux-stm32, linux-arm-kernel,
linux-kernel, Sashiko
On probe failure after stm32_iwdg_irq_init() or on driver unbind,
the struct wake_irq allocated by dev_pm_set_wake_irq() is leaked
and dev->power.wakeirq remains attached to the device.
Any subsequent attempt to re-probe the device hits the
dev->power.wakeirq check in dev_pm_attach_wake_irq(), triggers a
dev_WARN_ONCE() splat, and fails probe with -EEXIST.
Use the managed version devm_pm_set_wake_irq().
This is reported by Sashiko inside the raw log of another commit
that touches the same driver.
Fixes: 3ab1663af6c1 ("watchdog: stm32_iwdg: Add pretimeout support")
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/message/20261116132416.1184447-3-antonio.borneo%40foss.st.com
Link: https://sashiko.dev/#/log/249869
Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com>
---
drivers/watchdog/stm32_iwdg.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c
index a8d2db2d3cf8b..f1056f8100cf0 100644
--- a/drivers/watchdog/stm32_iwdg.c
+++ b/drivers/watchdog/stm32_iwdg.c
@@ -298,7 +298,7 @@ static int stm32_iwdg_irq_init(struct platform_device *pdev,
if (ret)
return ret;
- ret = dev_pm_set_wake_irq(dev, irq);
+ ret = devm_pm_set_wake_irq(dev, irq);
if (ret)
return ret;
}
base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] watchdog: stm32_iwdg: use managed variant of dev_pm_set_wake_irq()
2026-11-16 19:01 [PATCH] watchdog: stm32_iwdg: use managed variant of dev_pm_set_wake_irq() Antonio Borneo
@ 2026-11-16 19:09 ` sashiko-bot
2026-11-16 20:36 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-11-16 19:09 UTC (permalink / raw)
To: Antonio Borneo; +Cc: linux-watchdog
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Medium] watchdog: stm32_iwdg: NULL pointer dereference in
stm32_iwdg_isr() [1]
--
commit faff7513f5bea59db8a5e975f7eb126068ba7dc8
Author: Antonio Borneo <antonio.borneo@foss.st.com>
watchdog: stm32_iwdg: use managed variant of dev_pm_set_wake_irq()
This commit switches stm32_iwdg_irq_init() to use devm_pm_set_wake_irq()
so the wake IRQ is automatically detached on probe failure or driver
unbind.
Link: https://sashiko.dev/#/message/20261116132416.1184447-3-antonio.borneo%40foss.st.com
Link: https://sashiko.dev/#/log/249869
> diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c
> index a8d2db2d3cf8b..f1056f8100cf0 100644
> --- a/drivers/watchdog/stm32_iwdg.c
> +++ b/drivers/watchdog/stm32_iwdg.c
> @@ -298,7 +298,7 @@ static int stm32_iwdg_irq_init(struct platform_device *pdev,
> if (ret)
> return ret;
>
> - ret = dev_pm_set_wake_irq(dev, irq);
> + ret = devm_pm_set_wake_irq(dev, irq);
> if (ret)
> return ret;
> }
[Severity: Medium]
This problem wasn't introduced by this patch, but can stm32_iwdg_isr() hit
a NULL pointer dereference [1] if the interrupt fires before
watchdog_set_drvdata() runs?
stm32_iwdg_probe() calls stm32_iwdg_irq_init(), which requests the IRQ,
before populating wdd->driver_data:
drivers/watchdog/stm32_iwdg.c:stm32_iwdg_probe() {
...
ret = stm32_iwdg_irq_init(pdev, wdt);
if (ret)
return ret;
watchdog_set_drvdata(wdd, wdt);
...
}
If the watchdog is already running with the early-wakeup interrupt enabled
(for example across driver rebind) and the IRQ fires in that window,
stm32_iwdg_isr() gets NULL from watchdog_get_drvdata(wdd) and dereferences
wdt->regs.
[1] https://sashiko.dev/#/bug/linux-ebf60aef-da57-4fba-a11d-75c387866884
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116190130.1191501-1-antonio.borneo@foss.st.com?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] watchdog: stm32_iwdg: use managed variant of dev_pm_set_wake_irq()
2026-11-16 19:01 [PATCH] watchdog: stm32_iwdg: use managed variant of dev_pm_set_wake_irq() Antonio Borneo
2026-11-16 19:09 ` sashiko-bot
@ 2026-11-16 20:36 ` Guenter Roeck
1 sibling, 0 replies; 3+ messages in thread
From: Guenter Roeck @ 2026-11-16 20:36 UTC (permalink / raw)
To: Antonio Borneo
Cc: Wim Van Sebroeck, Maxime Coquelin, Alexandre Torgue,
Clément Le Goffic, Marek Vasut, linux-watchdog, linux-stm32,
linux-arm-kernel, linux-kernel, Sashiko
On Mon, Nov 16, 2026 at 08:01:30PM +0100, Antonio Borneo wrote:
> On probe failure after stm32_iwdg_irq_init() or on driver unbind,
> the struct wake_irq allocated by dev_pm_set_wake_irq() is leaked
> and dev->power.wakeirq remains attached to the device.
> Any subsequent attempt to re-probe the device hits the
> dev->power.wakeirq check in dev_pm_attach_wake_irq(), triggers a
> dev_WARN_ONCE() splat, and fails probe with -EEXIST.
>
> Use the managed version devm_pm_set_wake_irq().
>
> This is reported by Sashiko inside the raw log of another commit
> that touches the same driver.
>
> Fixes: 3ab1663af6c1 ("watchdog: stm32_iwdg: Add pretimeout support")
> Reported-by: Sashiko <sashiko-bot@kernel.org>
> Link: https://sashiko.dev/#/message/20261116132416.1184447-3-antonio.borneo%40foss.st.com
> Link: https://sashiko.dev/#/log/249869
> Signed-off-by: Antonio Borneo <antonio.borneo@foss.st.com>
Applied.
Thanks,
Guenter
> ---
> drivers/watchdog/stm32_iwdg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
>
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
>
> diff --git a/drivers/watchdog/stm32_iwdg.c b/drivers/watchdog/stm32_iwdg.c
> index a8d2db2d3cf8b..f1056f8100cf0 100644
> --- a/drivers/watchdog/stm32_iwdg.c
> +++ b/drivers/watchdog/stm32_iwdg.c
> @@ -298,7 +298,7 @@ static int stm32_iwdg_irq_init(struct platform_device *pdev,
> if (ret)
> return ret;
>
> - ret = dev_pm_set_wake_irq(dev, irq);
> + ret = devm_pm_set_wake_irq(dev, irq);
> if (ret)
> return ret;
> }
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-11-16 20:36 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-16 19:01 [PATCH] watchdog: stm32_iwdg: use managed variant of dev_pm_set_wake_irq() Antonio Borneo
2026-11-16 19:09 ` sashiko-bot
2026-11-16 20:36 ` Guenter Roeck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.