Skip to content

Commit 98dfa0a

Browse files
serhiy-katsyuba-intelnashif
authored andcommitted
pm: Fix to prevent incorrect forever timeout
K_TICKS_FOREVER is defined as -1. Guard logic has been added for the case when `ticks - exit_latency_ticks == -1` to prevent sys_clock_set_timeout() from incorrectly setting a forever timeout. Signed-off-by: Serhiy Katsyuba <[email protected]>
1 parent b634ede commit 98dfa0a

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

subsys/pm/pm.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,12 @@ bool pm_system_suspend(int32_t kernel_ticks)
199199
/*
200200
* We need to set the timer to interrupt a little bit early to
201201
* accommodate the time required by the CPU to fully wake up.
202+
*
203+
* Since K_TICKS_FOREVER is defined as -1, ensure that -1
204+
* is not passed as the next timeout.
205+
*
202206
*/
203-
sys_clock_set_timeout(ticks - exit_latency_ticks, true);
207+
sys_clock_set_timeout(MAX(0, ticks - exit_latency_ticks), true);
204208
}
205209

206210
/*

0 commit comments

Comments
 (0)