]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
watchdog: at91sam9_wdt: prevent timer rearm during teardown
authorHongyan Xu <getshell@seu.edu.cn>
Thu, 6 Aug 2026 06:06:13 +0000 (14:06 +0800)
committerGuenter Roeck <linux@roeck-us.net>
Thu, 6 Aug 2026 21:23:55 +0000 (14:23 -0700)
at91_ping() rearms the watchdog timer from its callback. timer_delete()
neither waits for a running callback nor prevents it from rearming the
timer, so probe failure or driver removal can leave the timer accessing the
devm-allocated at91wdt after it has been freed.

Use timer_shutdown_sync() on both teardown paths. It waits for a running
callback and rejects any attempt by the callback to rearm the timer.

Fixes: 5161b31dc39a ("watchdog: at91sam9_wdt: better watchdog support")
Signed-off-by: Hongyan Xu <getshell@seu.edu.cn>
Link: https://lore.kernel.org/r/20260806060613.1830-1-getshell@seu.edu.cn
Signed-off-by: Guenter Roeck <linux@roeck-us.net>
drivers/watchdog/at91sam9_wdt.c

index aba66b8e9d0339b7f9dbb6f5b3124c31f8df078a..80ba04df54adfd81728ae0653961ca13a8c93725 100644 (file)
@@ -242,7 +242,7 @@ static int at91_wdt_init(struct platform_device *pdev, struct at91wdt *wdt)
        return 0;
 
 out_stop_timer:
-       timer_delete(&wdt->timer);
+       timer_shutdown_sync(&wdt->timer);
        return err;
 }
 
@@ -378,7 +378,7 @@ static void at91wdt_remove(struct platform_device *pdev)
        watchdog_unregister_device(&wdt->wdd);
 
        pr_warn("I quit now, hardware will probably reboot!\n");
-       timer_delete(&wdt->timer);
+       timer_shutdown_sync(&wdt->timer);
 }
 
 #if defined(CONFIG_OF)