This is an automated email from Gerrit.

Tomas Vanek ([email protected]) just uploaded a new patch set to Gerrit, which you 
can find at http://openocd.zylin.com/5729

-- gerrit

commit 562bfaebc0d3bc83e8b0f477233fd4f2d311b4ec
Author: Tomas Vanek <[email protected]>
Date:   Mon Jun 29 13:34:07 2020 +0200

    arm_adi_v5: prevent possibly endless recursion in dap_dp_init()
    
    If dap_dp_read_atomic() in 30 trials loop fails, dap->do_reconnect is set.
    Following dap_dp_read_atomic() calls dap_queue_dp_read() which in case
    of SWD transport calls swd_queue_dp_read(). It starts
    with swd_check_reconnect() and it calls swd_connect() because
    dap->do_reconnect is set. swd_connect() does some initialization,
    reads DPIDR and calls dap_dp_init() again!
    
    Keep dap->do_reconnect unset to prevent unwanted recursion.
    
    Change-Id: I54052fdefe50bf5f7c7b59fe751fe2063d5710c9
    Signed-off-by: Tomas Vanek <[email protected]>

diff --git a/src/target/arm_adi_v5.c b/src/target/arm_adi_v5.c
index f19514c..97acfbb 100644
--- a/src/target/arm_adi_v5.c
+++ b/src/target/arm_adi_v5.c
@@ -669,6 +669,12 @@ int dap_dp_init(struct adiv5_dap *dap)
                retval = dap_dp_read_atomic(dap, DP_CTRL_STAT, NULL);
                if (retval == ERROR_OK)
                        break;
+
+               /* As we currently in the process of connecting SWD, reconnect
+                * does not make sense at this point. Moreover if dap_queue_xx
+                * operation is entered with do_reconnect set, at least on SWD 
we
+                * fall into possibly endless recursion */
+               dap->do_reconnect = false;
        }
 
        /*

-- 


_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to