History

watchdog: fix hrtimer start when pretimeout is zero

Per the watchdog API, a pretimeout value of 0 disables the feature. However, watchdog_hrtimer_pretimeout_start() fails to verify if the pretimeout is non-zero before arming the timer. This omission inadvertently starts the software pretimeout timer, which could result in the pretimeout handler executing incorrectly when the watchdog timeout is reached. Fix this by adding a check for wdd->pretimeout before calling hrtimer_start(), ensuring the disabled state is respected.

David Arcari committed 2 months ago

Commit 0fa37511 parent d83b7501 file · +1 −0Browse files

Unified · Split

drivers/watchdog/watchdog_hrtimer_pretimeout.c+1−0
@@ -30,6 +30,7 @@ void watchdog_hrtimer_pretimeout_init(struct watchdog_device *wdd) · 29 unmodified lines
30void watchdog_hrtimer_pretimeout_start(struct watchdog_device *wdd)30void watchdog_hrtimer_pretimeout_start(struct watchdog_device *wdd)
31{31{
32 if (!(wdd->info->options & WDIOF_PRETIMEOUT) &&32 if (!(wdd->info->options & WDIOF_PRETIMEOUT) &&
33 wdd->pretimeout &&
33 !watchdog_pretimeout_invalid(wdd, wdd->pretimeout))34 !watchdog_pretimeout_invalid(wdd, wdd->pretimeout))
34 hrtimer_start(&wdd->wd_data->pretimeout_timer,35 hrtimer_start(&wdd->wd_data->pretimeout_timer,
35 ktime_set(wdd->timeout - wdd->pretimeout, 0),36 ktime_set(wdd->timeout - wdd->pretimeout, 0),