Re: [PATCH 3/8] watchdog: core: Prevent ping worker from re-arming timer on suspend

From: Tzung-Bi Shih

Date: Wed Sep 30 2026 - 07:58:44 EST


On Tue, Sep 29, 2026 at 06:46:30AM -0700, Guenter Roeck wrote:
> In watchdog_dev_suspend(), hrtimer_cancel() is called before
> kthread_cancel_work_sync(). If the timer expired just before
> hrtimer_cancel() and queued watchdog_ping_work(), the worker can run
> and acquire wd_data->lock while kthread_cancel_work_sync() waits for it
> to finish. Because no state flag indicates that the watchdog is
> suspended, watchdog_worker_should_ping() returns true and
> __watchdog_ping() re-arms wd_data->timer while the device is suspended.
>
> Add a _WDOG_SUSPENDED internal status bit to wd_data->status, set it
> under wd_data->lock in watchdog_dev_suspend(), clear it under
> wd_data->lock in watchdog_dev_resume(), and check it in
> watchdog_worker_should_ping(), watchdog_need_worker(), and
> __watchdog_ping() so the timer cannot be armed while suspended.
>
> Fixes: 60bcd91aafd2 ("watchdog: introduce watchdog_dev_suspend/resume")
> Assisted-by: LLM
> Signed-off-by: Guenter Roeck <linux@xxxxxxxxxxxx>

Reviewed-by: Tzung-Bi Shih <tzungbi@xxxxxxxxxx>