From 50f801dfaa245e8db3077e8541d93ad7b7426d85 Mon Sep 17 00:00:00 2001 From: ouyangxiangzhen Date: Fri, 5 Jul 2024 19:24:34 +0800 Subject: [PATCH] sched/wdog: Fix list traversal problem in nested wdog process If g_wdactivelist has been changed in the wdog callback, the list traversal with next pointer will cause problem. Signed-off-by: ouyangxiangzhen Signed-off-by: ligd --- sched/wdog/wd_start.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sched/wdog/wd_start.c b/sched/wdog/wd_start.c index 02c7a58ddd..0fdb48213b 100644 --- a/sched/wdog/wd_start.c +++ b/sched/wdog/wd_start.c @@ -91,16 +91,16 @@ static inline_function void wd_expiration(clock_t ticks) { FAR struct wdog_s *wdog; - FAR struct wdog_s *next; wdentry_t func; /* Process the watchdog at the head of the list as well as any * other watchdogs that became ready to run at this time */ - list_for_every_entry_safe(&g_wdactivelist, wdog, - next, struct wdog_s, node) + while (!list_is_empty(&g_wdactivelist)) { + wdog = list_first_entry(&g_wdactivelist, struct wdog_s, node); + /* Check if expected time is expired */ if (!clock_compare(wdog->expired, ticks))