From 94346d2441fc8c80f5ae85e0faab4963e56fff81 Mon Sep 17 00:00:00 2001 From: Yong Cong Sin Date: Sun, 26 May 2024 16:16:20 +0800 Subject: [PATCH] arch: arm64: fatal: limit max number of stack traces In some cases, the `fp` will never be `NULL` and the stack unwinding can go on and on forever, limit the max depth so that this will not happen. Signed-off-by: Yong Cong Sin --- arch/arm64/core/fatal.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/arm64/core/fatal.c b/arch/arm64/core/fatal.c index 86a07632c5a..87e5a2441c6 100644 --- a/arch/arm64/core/fatal.c +++ b/arch/arm64/core/fatal.c @@ -223,7 +223,7 @@ static void esf_unwind(const z_arch_esf_t *esf) uint64_t lr; LOG_ERR(""); - while (fp != NULL) { + for (int i = 0; (fp != NULL) && (i < CONFIG_EXCEPTION_STACK_TRACE_MAX_FRAMES); i++) { lr = fp[1]; #ifdef CONFIG_SYMTAB uint32_t offset = 0;