sched/wdog: Reject zero delay in wd_start_next.

wd_start_next() schedules relative to the previous expiration.  A zero
value reuses that expiration, so a callback can immediately reinsert an
already expired watchdog and make wd_expiration() loop without advancing
time.

Reject non-positive delays to guarantee that the next expiration advances.

Assisted-by: OpenAI Codex <noreply@openai.com>
Signed-off-by: yushuailong <yyyusl@qq.com>
This commit is contained in:
yushuailong 2026-09-26 12:16:14 +08:00 • committed by Xiang Xiao
parent bfb2cd5541
commit e5d9960f56

View file

@ -309,7 +309,7 @@ int wd_start_realtime(FAR struct wdog_s *wdog,
*
* Input Parameters:
* wdog - Pointer of the periodic watchdog.
* delay - Delayed time in system ticks.
* delay - Positive delay in system ticks.
* wdentry - Function to call on timeout.
* arg - Parameter to pass to wdentry.
*
@ -331,7 +331,7 @@ int wd_start_next(FAR struct wdog_s *wdog, clock_t delay,
{
/* Ensure delay is within the range the wdog can handle. */
if (delay < 0 || delay > WDOG_MAX_DELAY)
if (delay <= 0 || delay > WDOG_MAX_DELAY)
{
return -EINVAL;
}