target/adi_v5_swd: fix segfault when calling jtag_to_swd

When SWD mode is not supported by the target adapter, the call should
return an error instead of segfaulting.

Change-Id: I1626097deb93ecfbe78a6e82d812c7a673dbbde5
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2256
Tested-by: jenkins
This commit is contained in:
Paul Fertser 2014-08-17 12:19:47 +04:00 committed by Andreas Fritiofson
parent bd0409aa93
commit f8318d1b0d
1 changed files with 5 additions and 0 deletions

View File

@ -253,6 +253,11 @@ int dap_to_swd(struct target *target)
struct arm *arm = target_to_arm(target); struct arm *arm = target_to_arm(target);
int retval; int retval;
if (!arm->dap) {
LOG_ERROR("SWD mode is not available");
return ERROR_FAIL;
}
LOG_DEBUG("Enter SWD mode"); LOG_DEBUG("Enter SWD mode");
/* REVISIT it's ugly to need to make calls to a "jtag" /* REVISIT it's ugly to need to make calls to a "jtag"