cortex_m: don't try to halt not-examined targets

Prevent a segmentation fault by preventing to try to halt a target
that has not been examined yet.

Change-Id: I5d344e7fbdb5422f7c5e2c39bdd48cbc6c2a3e58
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/8213
Tested-by: jenkins
This commit is contained in:
Antonio Borneo 2024-04-08 17:40:09 +02:00
parent 8667a72653
commit 89d881c19a
1 changed files with 5 additions and 0 deletions

View File

@ -1109,6 +1109,11 @@ static int cortex_m_halt_one(struct target *target)
int retval;
LOG_TARGET_DEBUG(target, "target->state: %s", target_state_name(target));
if (!target_was_examined(target)) {
LOG_TARGET_ERROR(target, "target non examined yet");
return ERROR_TARGET_NOT_EXAMINED;
}
if (target->state == TARGET_HALTED) {
LOG_TARGET_DEBUG(target, "target was already halted");
return ERROR_OK;