From fd402083d7d65092059002c44e70e22bb9e54e23 Mon Sep 17 00:00:00 2001 From: apio Date: Sat, 6 Jan 2024 18:12:25 +0100 Subject: [PATCH] kernel: Fix kernel panic when adding a timer before another one This was caused because add_to_timer_queue() did not set active_clock when inserting a timer before the end, making disarm() a no-op. Therefore, the clock would continue to use the timer after it had been freed. --- kernel/src/thread/Clock.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/kernel/src/thread/Clock.cpp b/kernel/src/thread/Clock.cpp index 1fb6c8bb..2cf28b3b 100644 --- a/kernel/src/thread/Clock.cpp +++ b/kernel/src/thread/Clock.cpp @@ -79,6 +79,7 @@ void Clock::add_to_timer_queue(Timer* timer) { t->delta_ticks -= timer->delta_ticks; m_timer_queue.add_before(t, timer); + timer->active_clock = this; return; } timer->delta_ticks -= t->delta_ticks;