From d303e556add161a8a1cc64a981383ecd3a8a6896 Mon Sep 17 00:00:00 2001 From: Kevin O'Connor Date: Thu, 21 Dec 2017 12:41:27 -0500 Subject: [PATCH] sched: Interrupts must be disabled during setjmp() call On the AVR platform (and possibly others) the longjmp() call will restore the interrupt state saved during the setjmp() call. So, the setjmp() call must be invoked with interrupts disabled to ensure that shutdown handling is run with interrupts disabled. This fixes potential corruption of the shutdown processing on AVR. Signed-off-by: Kevin O'Connor --- src/sched.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/sched.c b/src/sched.c index f278c426..248d3c68 100644 --- a/src/sched.c +++ b/src/sched.c @@ -282,6 +282,7 @@ sched_clear_shutdown(void) static void run_shutdown(int reason) { + irq_disable(); uint32_t cur = timer_read_time(); if (!shutdown_status) shutdown_reason = reason; @@ -334,9 +335,11 @@ sched_main(void) sendf("starting"); + irq_disable(); int ret = setjmp(shutdown_jmp); if (ret) run_shutdown(ret); + irq_enable(); run_tasks(); }