etm: prevent segfault when reading bogus information
[openocd.git] / src / target / etm.c
index e99c24ffbec36f1bdf8e64f1665ae7ac8b6f0c84..be5dd020a28349908857bf2146e8786617724fbf 100644 (file)
@@ -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)

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)