diff --git a/arch/riscv/core/fatal.c b/arch/riscv/core/fatal.c index 31ead071eb9..2624edbec90 100644 --- a/arch/riscv/core/fatal.c +++ b/arch/riscv/core/fatal.c @@ -107,7 +107,7 @@ FUNC_NORETURN void z_riscv_fatal_error_csf(unsigned int reason, const z_arch_esf LOG_ERR(""); } - if (IS_ENABLED(CONFIG_RISCV_EXCEPTION_STACK_TRACE)) { + if (IS_ENABLED(CONFIG_RISCV_EXCEPTION_STACK_TRACE) && (esf != NULL)) { z_riscv_unwind_stack(esf); } diff --git a/arch/riscv/core/stacktrace.c b/arch/riscv/core/stacktrace.c index e0c97b642ba..9c6c013efae 100644 --- a/arch/riscv/core/stacktrace.c +++ b/arch/riscv/core/stacktrace.c @@ -88,10 +88,6 @@ void z_riscv_unwind_stack(const z_arch_esf_t *esf) uintptr_t ra; struct stackframe *frame; - if (esf == NULL) { - return; - } - LOG_ERR("call trace:"); for (int i = 0; (i < MAX_STACK_FRAMES) && (fp != 0U) && in_stack_bound(fp);) { @@ -121,10 +117,6 @@ void z_riscv_unwind_stack(const z_arch_esf_t *esf) uintptr_t ra; uintptr_t *ksp = (uintptr_t *)sp; - if (esf == NULL) { - return; - } - LOG_ERR("call trace:"); for (int i = 0;