target/target: Check checksum_memory before call

Make sure checksum_memory is present.  Otherwise it'll segfault.

Change-Id: If31123323bd8a03282da43505c9604fde735ad0e
Signed-off-by: Yasushi SHOJI <yashi@spacecubics.com>
Reviewed-on: https://review.openocd.org/c/openocd/+/6758
Tested-by: jenkins
Reviewed-by: Antonio Borneo <borneo.antonio@gmail.com>
This commit is contained in:
Yasushi SHOJI 2021-11-29 22:33:27 +09:00 committed by Antonio Borneo
parent 2753c9868e
commit d7142a5727
1 changed files with 4 additions and 0 deletions

View File

@ -2530,6 +2530,10 @@ int target_checksum_memory(struct target *target, target_addr_t address, uint32_
LOG_ERROR("Target not examined yet");
return ERROR_FAIL;
}
if (!target->type->checksum_memory) {
LOG_ERROR("Target %s doesn't support checksum_memory", target_name(target));
return ERROR_FAIL;
}
retval = target->type->checksum_memory(target, address, size, &checksum);
if (retval != ERROR_OK) {