This is an automated email from Gerrit.

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

-- gerrit

commit e7875ada28e3b9fa794d1424903144f13a100f59
Author: Paul Fertser <[email protected]>
Date:   Tue Jul 16 11:29:15 2013 +0400

    etm: prevent segfault when reading bogus information
    
    When I do not have the JTAG adapter connected to the target, I often
    end up always reading 1s from the chain. If the OpenOCD is configured
    to connect to an ETM-equipped target (i.MX25 ARM9 in my case), this
    results in writing garbage values in the etm reg_cache as the ETM bit
    fields for the comparators, counters and outputs are wider than the
    amount of entries in the corresponding arrays. This later results in a
    segfault in the first etm_reg_lookup() call.
    
    Change-Id: Ied81fdbf3a53a3dd749e2e5e97adf86c012df575
    Signed-off-by: Paul Fertser <[email protected]>

diff --git a/src/target/etm.c b/src/target/etm.c
index e99c24f..be5dd02 100644
--- a/src/target/etm.c
+++ b/src/target/etm.c
@@ -144,6 +144,7 @@ static const struct etm_reg_info etm_addr_comp[] = {
        ADDR_COMPARATOR(14),
        ADDR_COMPARATOR(15),
        ADDR_COMPARATOR(16),
+       { 0, 0, 0, 0, NULL }
 #undef ADDR_COMPARATOR
 };
 
@@ -162,6 +163,7 @@ static const struct etm_reg_info etm_data_comp[] = {
        DATA_COMPARATOR(6),
        DATA_COMPARATOR(7),
        DATA_COMPARATOR(8),
+       { 0, 0, 0, 0, NULL }
 #undef DATA_COMPARATOR
 };
 
@@ -179,6 +181,7 @@ static const struct etm_reg_info etm_counters[] = {
        ETM_COUNTER(2),
        ETM_COUNTER(3),
        ETM_COUNTER(4),
+       { 0, 0, 0, 0, NULL }
 #undef ETM_COUNTER
 };
 
@@ -206,6 +209,7 @@ static const struct etm_reg_info etm_outputs[] = {
        ETM_OUTPUT(2),
        ETM_OUTPUT(3),
        ETM_OUTPUT(4),
+       { 0, 0, 0, 0, NULL }
 #undef ETM_OUTPUT
 };
 
@@ -265,6 +269,11 @@ static void etm_reg_add(unsigned bcd_vers, struct arm_jtag 
*jtag_info,
         * version of the ETM, to the specified cache.
         */
        for (; nreg--; r++) {
+               /* No more registers to add */
+               if (!r->size) {
+                       LOG_ERROR("etm_reg_add is requested to add non-existing 
registers, ETM config might be bogus");
+                       return;
+               }
 
                /* this ETM may be too old to have some registers */
                if (r->bcd_vers > bcd_vers)

-- 

------------------------------------------------------------------------------
See everything from the browser to the database with AppDynamics
Get end-to-end visibility with application monitoring from AppDynamics
Isolate bottlenecks and diagnose root cause in seconds.
Start your free trial of AppDynamics Pro today!
http://pubads.g.doubleclick.net/gampad/clk?id=48808831&iu=/4140/ostg.clktrk
_______________________________________________
OpenOCD-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to