From 1ba23ca92b06a54ca77ec030b3049f6283277e5f Mon Sep 17 00:00:00 2001 From: Krzysztof Chruscinski Date: Wed, 14 Apr 2021 13:38:01 +0200 Subject: [PATCH] kernel: fatal: Avoid thread api access when no multithreading Remove access to thread API when multithreading is off. Signed-off-by: Krzysztof Chruscinski --- kernel/fatal.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/fatal.c b/kernel/fatal.c index cd2876b5253..522cba33797 100644 --- a/kernel/fatal.c +++ b/kernel/fatal.c @@ -98,7 +98,8 @@ void z_fatal_error(unsigned int reason, const z_arch_esf_t *esf) * appropriate. */ unsigned int key = arch_irq_lock(); - struct k_thread *thread = k_current_get(); + struct k_thread *thread = IS_ENABLED(CONFIG_MULTITHREADING) ? + k_current_get() : NULL; /* twister looks for the "ZEPHYR FATAL ERROR" string, don't * change it without also updating twister @@ -179,5 +180,8 @@ void z_fatal_error(unsigned int reason, const z_arch_esf_t *esf) } arch_irq_unlock(key); - k_thread_abort(thread); + + if (IS_ENABLED(CONFIG_MULTITHREADING)) { + k_thread_abort(thread); + } }