[PATCH] watchdog/sama5d4: set platform driver data before requesting IRQ
From: Rosen Penev
Date: Tue Jun 02 2026 - 21:09:31 EST
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@xxxxxxxxx>
---
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