Commit 5b34018c authored by Andreas Fritiofson's avatar Andreas Fritiofson Committed by Spencer Oliver
Browse files

fix segfault from stack corruption in ahbap_debugport_init



ahbap_debugport_init was queueing reads to a local stack variable but
didn't execute the queue before returning. Since the result of the reads
are not used anyway, it's better to pass NULL as the destination instead of
a dummy variable. I changed this throughout the function, even for the
reads that were actually executed.
Signed-off-by: default avatarAndreas Fritiofson <andreas.fritiofson@gmail.com>
Signed-off-by: default avatarSpencer Oliver <ntfreak@users.sourceforge.net>
parent a7274181
...@@ -906,7 +906,6 @@ extern const struct dap_ops jtag_dp_ops; ...@@ -906,7 +906,6 @@ extern const struct dap_ops jtag_dp_ops;
*/ */
int ahbap_debugport_init(struct adiv5_dap *dap) int ahbap_debugport_init(struct adiv5_dap *dap)
{ {
uint32_t dummy;
uint32_t ctrlstat; uint32_t ctrlstat;
int cnt = 0; int cnt = 0;
int retval; int retval;
...@@ -931,7 +930,7 @@ int ahbap_debugport_init(struct adiv5_dap *dap) ...@@ -931,7 +930,7 @@ int ahbap_debugport_init(struct adiv5_dap *dap)
/* DP initialization */ /* DP initialization */
retval = dap_queue_dp_read(dap, DP_CTRL_STAT, &dummy); retval = dap_queue_dp_read(dap, DP_CTRL_STAT, NULL);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
...@@ -939,7 +938,7 @@ int ahbap_debugport_init(struct adiv5_dap *dap) ...@@ -939,7 +938,7 @@ int ahbap_debugport_init(struct adiv5_dap *dap)
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
retval = dap_queue_dp_read(dap, DP_CTRL_STAT, &dummy); retval = dap_queue_dp_read(dap, DP_CTRL_STAT, NULL);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
...@@ -977,7 +976,7 @@ int ahbap_debugport_init(struct adiv5_dap *dap) ...@@ -977,7 +976,7 @@ int ahbap_debugport_init(struct adiv5_dap *dap)
alive_sleep(10); alive_sleep(10);
} }
retval = dap_queue_dp_read(dap, DP_CTRL_STAT, &dummy); retval = dap_queue_dp_read(dap, DP_CTRL_STAT, NULL);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
/* With debug power on we can activate OVERRUN checking */ /* With debug power on we can activate OVERRUN checking */
...@@ -985,7 +984,7 @@ int ahbap_debugport_init(struct adiv5_dap *dap) ...@@ -985,7 +984,7 @@ int ahbap_debugport_init(struct adiv5_dap *dap)
retval = dap_queue_dp_write(dap, DP_CTRL_STAT, dap->dp_ctrl_stat); retval = dap_queue_dp_write(dap, DP_CTRL_STAT, dap->dp_ctrl_stat);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
retval = dap_queue_dp_read(dap, DP_CTRL_STAT, &dummy); retval = dap_queue_dp_read(dap, DP_CTRL_STAT, NULL);
if (retval != ERROR_OK) if (retval != ERROR_OK)
return retval; return retval;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment