summaryrefslogtreecommitdiff
path: root/src/transport
diff options
context:
space:
mode:
authorTomek CEDRO <cederom@tlen.pl>2011-11-06 04:22:20 +0000
committerTomek CEDRO <cederom@tlen.pl>2011-11-06 04:22:20 +0000
commitbe7702685e5819a6744cdaae283ebe25be9bdec4 (patch)
tree43218f5e7fa4b69c2c029f1835753bb51f122813 /src/transport
parent2c1702116d1bd4d39fdde3ded710ed8e2a55dba3 (diff)
downloadopenocd+libswd-be7702685e5819a6744cdaae283ebe25be9bdec4.tar.gz
openocd+libswd-be7702685e5819a6744cdaae283ebe25be9bdec4.tar.bz2
openocd+libswd-be7702685e5819a6744cdaae283ebe25be9bdec4.tar.xz
openocd+libswd-be7702685e5819a6744cdaae283ebe25be9bdec4.zip
transport/swd: Fixed critical bugs in AP/DP read code: 1. double pointer did not return data where is should, 2. calling reads with NULL pointer caused program crash.
Diffstat (limited to 'src/transport')
-rw-r--r--src/transport/swd_core.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/transport/swd_core.c b/src/transport/swd_core.c
index cc9109d6..c18c111a 100644
--- a/src/transport/swd_core.c
+++ b/src/transport/swd_core.c
@@ -61,12 +61,13 @@ int oocd_swd_queue_idcode_read(struct adiv5_dap *dap, uint8_t *ack, uint32_t *da
}
int oocd_swd_queue_dp_read(struct adiv5_dap *dap, unsigned reg, uint32_t *data){
- int retval;
- retval=swd_dp_read((swd_ctx_t *)dap->ctx, SWD_OPERATION_EXECUTE, reg, (int**) &data);
+ int retval, *rdata;
+ retval=swd_dp_read((swd_ctx_t *)dap->ctx, SWD_OPERATION_EXECUTE, reg, &rdata);
if (retval<0){
LOG_ERROR("swd_dp_read() error: %s ", swd_error_string(retval));
return ERROR_FAIL;
}
+ if (data!=NULL) *data=(uint32_t)*rdata;
return ERROR_OK;
}
@@ -81,12 +82,13 @@ int oocd_swd_queue_dp_write(struct adiv5_dap *dap, unsigned reg, uint32_t data){
}
int oocd_swd_queue_ap_read(struct adiv5_dap *dap, unsigned reg, uint32_t *data){
- int retval;
- retval=swd_ap_read((swd_ctx_t *)dap->ctx, SWD_OPERATION_EXECUTE, (char) reg, (int**) &data);
+ int retval, *rdata;
+ retval=swd_ap_read((swd_ctx_t *)dap->ctx, SWD_OPERATION_EXECUTE, (char) reg, &rdata);
if (retval<0){
LOG_ERROR("swd_ap_read() error: %s ", swd_error_string(retval));
return ERROR_FAIL;
}
+ if (data!=NULL) *data=*rdata;
return ERROR_OK;
}