aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cortexm.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/cortexm.c b/src/cortexm.c
index 1142394..8c2e54e 100644
--- a/src/cortexm.c
+++ b/src/cortexm.c
@@ -693,6 +693,8 @@ static int cortexm_fault_unwind(struct target_s *target)
/* Read stack for pre-exception registers */
uint32_t sp = spsel ? regs[REG_PSP] : regs[REG_MSP];
target_mem_read_words(target, stack, sp, sizeof(stack));
+ if (target_check_error(target))
+ return 0;
regs[REG_LR] = stack[5]; /* restore LR to pre-exception state */
regs[REG_PC] = stack[6]; /* restore PC to pre-exception state */