From ad110d495ebc5439bb97dc48d4280a732742f384 Mon Sep 17 00:00:00 2001 From: Andrew Boie Date: Wed, 21 Oct 2020 10:43:20 -0700 Subject: [PATCH] kernel: fatal: check if _current is NULL Arches which have custom swap to main can have _current be NULL very, very early in the boot process. Check this to avoid an infinite loop of fatal errors. Signed-off-by: Andrew Boie --- kernel/fatal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kernel/fatal.c b/kernel/fatal.c index 1922e320aca..077c6f8b691 100644 --- a/kernel/fatal.c +++ b/kernel/fatal.c @@ -48,7 +48,7 @@ __weak void k_sys_fatal_error_handler(unsigned int reason, static const char *thread_name_get(struct k_thread *thread) { - const char *thread_name = k_thread_name_get(thread); + const char *thread_name = thread ? k_thread_name_get(thread) : NULL; if (thread_name == NULL || thread_name[0] == '\0') { thread_name = "unknown";