From: Paul Fertser Date: Sun, 17 Aug 2014 08:19:47 +0000 (+0400) Subject: target/adi_v5_swd: fix segfault when calling jtag_to_swd X-Git-Tag: v0.9.0-rc1~293 X-Git-Url: https://review.openocd.org/gitweb?p=openocd.git;a=commitdiff_plain;h=f8318d1b0d873ea4b4b78d2d5a71cf52932e4762;ds=sidebyside 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 Reviewed-on: http://openocd.zylin.com/2256 Tested-by: jenkins --- diff --git a/src/target/adi_v5_swd.c b/src/target/adi_v5_swd.c index f8d3650edb..6e322fb411 100644 --- a/src/target/adi_v5_swd.c +++ b/src/target/adi_v5_swd.c @@ -253,6 +253,11 @@ int dap_to_swd(struct target *target) struct arm *arm = target_to_arm(target); int retval; + if (!arm->dap) { + LOG_ERROR("SWD mode is not available"); + return ERROR_FAIL; + } + LOG_DEBUG("Enter SWD mode"); /* REVISIT it's ugly to need to make calls to a "jtag"