target/armv7m: check error in armv7m_restore_context()

Return error if arm.write_core_reg() fails.

Change-Id: Ide8f5aa5958532b202dc9f5e13d3250a706d832d
Signed-off-by: Tomas Vanek <vanekt@fbl.cz>
Reviewed-on: https://review.openocd.org/c/openocd/+/7238
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Tomas Vanek 2022-10-01 17:00:51 +02:00 committed by Antonio Borneo
parent d0436b0cda
commit 083100fca3
1 changed files with 5 additions and 2 deletions

View File

@ -182,8 +182,11 @@ int armv7m_restore_context(struct target *target)
for (i = cache->num_regs - 1; i >= 0; i--) {
struct reg *r = &cache->reg_list[i];
if (r->exist && r->dirty)
armv7m->arm.write_core_reg(target, r, i, ARM_MODE_ANY, r->value);
if (r->exist && r->dirty) {
int retval = armv7m->arm.write_core_reg(target, r, i, ARM_MODE_ANY, r->value);
if (retval != ERROR_OK)
return retval;
}
}
return ERROR_OK;