* [PATCH] watchdog/sama5d4: set platform driver data before requesting IRQ
@ 2026-06-03 1:07 Rosen Penev
0 siblings, 0 replies; only message in thread
From: Rosen Penev @ 2026-06-03 1:07 UTC (permalink / raw)
To: linux-watchdog
Cc: Nicolas Ferre, Alexandre Belloni, Claudiu Beznea,
Wim Van Sebroeck, Guenter Roeck,
moderated list:ARM/Microchip (AT91) SoC support, open list
sama5d4_wdt_probe() requests a shared IRQ before calling
platform_set_drvdata(). Because the IRQ is shared, the handler
(sama5d4_wdt_irq_handler) can fire immediately, at which point
platform_get_drvdata() returns NULL and the subsequent dereference
of wdt->sam9x60_support causes a NULL pointer crash.
Move platform_set_drvdata() to the beginning of probe, right after
watchdog_set_drvdata(), so the handler always sees valid driver data.
Assisted-by: opencode:big-pickle
Signed-off-by: Rosen Penev <rosenp@gmail.com>
---
drivers/watchdog/sama5d4_wdt.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/watchdog/sama5d4_wdt.c b/drivers/watchdog/sama5d4_wdt.c
index e82b91513fa8..024300299b57 100644
--- a/drivers/watchdog/sama5d4_wdt.c
+++ b/drivers/watchdog/sama5d4_wdt.c
@@ -267,6 +267,7 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
: AT91_WDT_WDDIS;
watchdog_set_drvdata(wdd, wdt);
+ platform_set_drvdata(pdev, wdt);
regs = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(regs))
@@ -315,8 +316,6 @@ static int sama5d4_wdt_probe(struct platform_device *pdev)
if (ret)
return ret;
- platform_set_drvdata(pdev, wdt);
-
dev_info(dev, "initialized (timeout = %d sec, nowayout = %d)\n",
wdd->timeout, nowayout);
--
2.54.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-03 1:07 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-03 1:07 [PATCH] watchdog/sama5d4: set platform driver data before requesting IRQ Rosen Penev
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®