diff --git a/kernel/fatal.c b/kernel/fatal.c index 7917945c992..d11b6cf9620 100644 --- a/kernel/fatal.c +++ b/kernel/fatal.c @@ -112,7 +112,7 @@ void z_fatal_error(unsigned int reason, const z_arch_esf_t *esf) * See #17656 */ #if defined(CONFIG_ARCH_HAS_NESTED_EXCEPTION_DETECTION) - if (arch_is_in_nested_exception(esf)) { + if ((esf != NULL) && arch_is_in_nested_exception(esf)) { LOG_ERR("Fault during interrupt handling\n"); } #endif @@ -140,7 +140,7 @@ void z_fatal_error(unsigned int reason, const z_arch_esf_t *esf) "Attempted to recover from a kernel panic condition"); /* FIXME: #17656 */ #if defined(CONFIG_ARCH_HAS_NESTED_EXCEPTION_DETECTION) - if (arch_is_in_nested_exception(esf)) { + if ((esf != NULL) && arch_is_in_nested_exception(esf)) { #if defined(CONFIG_STACK_SENTINEL) if (reason != K_ERR_STACK_CHK_FAIL) { __ASSERT(0, @@ -152,7 +152,7 @@ void z_fatal_error(unsigned int reason, const z_arch_esf_t *esf) } else { /* Test mode */ #if defined(CONFIG_ARCH_HAS_NESTED_EXCEPTION_DETECTION) - if (arch_is_in_nested_exception(esf)) { + if ((esf != NULL) && arch_is_in_nested_exception(esf)) { /* Abort the thread only on STACK Sentinel check fail. */ #if defined(CONFIG_STACK_SENTINEL) if (reason != K_ERR_STACK_CHK_FAIL) {