Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

kernel: Fix double-list-removal corruption case in timeout handling #9620

Merged
merged 2 commits into from
Aug 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions kernel/include/timeout_q.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,9 @@ static inline void _handle_one_expired_timeout(struct _timeout *timeout)

static inline void _handle_expired_timeouts(sys_dlist_t *expired)
{
struct _timeout *timeout, *next;
struct _timeout *timeout;

SYS_DLIST_FOR_EACH_CONTAINER_SAFE(expired, timeout, next, node) {
sys_dlist_remove(&timeout->node);
SYS_DLIST_FOR_EACH_CONTAINER(expired, timeout, node) {
_handle_one_expired_timeout(timeout);
}
}
Expand Down
6 changes: 0 additions & 6 deletions kernel/sys_clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,6 @@ u32_t k_uptime_delta_32(s64_t *reftime)
* interrupt.
*/

volatile int _handling_timeouts;

static inline void handle_timeouts(s32_t ticks)
{
sys_dlist_t expired;
Expand Down Expand Up @@ -198,8 +196,6 @@ static inline void handle_timeouts(s32_t ticks)
* prohibited.
*/

_handling_timeouts = 1;

while (next) {

/*
Expand Down Expand Up @@ -254,8 +250,6 @@ static inline void handle_timeouts(s32_t ticks)
irq_unlock(key);

_handle_expired_timeouts(&expired);

_handling_timeouts = 0;
}
#else
#define handle_timeouts(ticks) do { } while ((0))
Expand Down