mips32, dsp563xx: fix segfault on Gdb attach 02/2102/2
authorPaul Fertser <fercerpav@gmail.com>
Sat, 12 Apr 2014 13:22:00 +0000 (17:22 +0400)
committerPaul Fertser <fercerpav@gmail.com>
Mon, 14 Apr 2014 18:18:13 +0000 (18:18 +0000)
Since c6216201b249e6a97fcc085e413e3d34e0de6fb7 gdb target description
generation support is enabled by default and it counts on checking
"feature" pointer in reg_list. Both mips32 and dsp563xx neither used
calloc nor explicitly set feature (as it was a newly introduced struct
field).

This patch changes all targets to use calloc for consistency.

Change-Id: I9eceadef8b04aacb108e24ae23cb51ca3009586f
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2102
Tested-by: jenkins
Reviewed-by: Salvador Arroyo <sarroyofdez@yahoo.es>
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/target/avr32_ap7k.c
src/target/dsp563xx.c
src/target/lakemont.c
src/target/mips32.c
src/target/openrisc/or1k.c

index 70af8c3ed5615db120bb8471febc7d4f5d3abbf7..e1812eccb049dfdd47d1a698ee24c817aac84c3b 100644 (file)
@@ -178,7 +178,7 @@ static struct reg_cache *avr32_build_reg_cache(struct target *target)
        struct avr32_ap7k_common *ap7k = target_to_ap7k(target);
        struct reg_cache **cache_p = register_get_last_cache_p(&target->reg_cache);
        struct reg_cache *cache = malloc(sizeof(struct reg_cache));
-       struct reg *reg_list = malloc(sizeof(struct reg) * num_regs);
+       struct reg *reg_list = calloc(num_regs, sizeof(struct reg));
        struct avr32_core_reg *arch_info =
                malloc(sizeof(struct avr32_core_reg) * num_regs);
        int i;
index 07df36338905e337cc5421e8c736a2c69ec4beef..2e7ac9612617bdd56c6805ac79f09a1e7763f59a 100644 (file)
@@ -451,7 +451,7 @@ static void dsp563xx_build_reg_cache(struct target *target)
 
        struct reg_cache **cache_p = register_get_last_cache_p(&target->reg_cache);
        struct reg_cache *cache = malloc(sizeof(struct reg_cache));
-       struct reg *reg_list = malloc(sizeof(struct reg) * DSP563XX_NUMCOREREGS);
+       struct reg *reg_list = calloc(DSP563XX_NUMCOREREGS, sizeof(struct reg));
        struct dsp563xx_core_reg *arch_info = malloc(
                        sizeof(struct dsp563xx_core_reg) * DSP563XX_NUMCOREREGS);
        int i;
index 70c785c6a55cc9453e527d0445dc5590317349d2..f3795c180bd78a6c4f4c0a74381805076e75ad28 100644 (file)
@@ -375,7 +375,7 @@ struct reg_cache *lakemont_build_reg_cache(struct target *t)
        int num_regs = ARRAY_SIZE(regs);
        struct reg_cache **cache_p = register_get_last_cache_p(&t->reg_cache);
        struct reg_cache *cache = malloc(sizeof(struct reg_cache));
-       struct reg *reg_list = malloc(sizeof(struct reg) * num_regs);
+       struct reg *reg_list = calloc(num_regs, sizeof(struct reg));
        struct lakemont_core_reg *arch_info = malloc(sizeof(struct lakemont_core_reg) * num_regs);
        struct reg_feature *feature;
        int i;
index 11f39fea881d6b1c43944c8a97236314c38eddf8..7cf5477dcaefeea15141e8374919e71569987120 100644 (file)
@@ -252,7 +252,7 @@ struct reg_cache *mips32_build_reg_cache(struct target *target)
        int num_regs = MIPS32NUMCOREREGS;
        struct reg_cache **cache_p = register_get_last_cache_p(&target->reg_cache);
        struct reg_cache *cache = malloc(sizeof(struct reg_cache));
-       struct reg *reg_list = malloc(sizeof(struct reg) * num_regs);
+       struct reg *reg_list = calloc(num_regs, sizeof(struct reg));
        struct mips32_core_reg *arch_info = malloc(sizeof(struct mips32_core_reg) * num_regs);
        int i;
 
index f26a01629745615815f2054f69fcc94eaefb101d..5852fc71fc96d33f1f5f4588188e26bc89f8629a 100644 (file)
@@ -513,7 +513,7 @@ static struct reg_cache *or1k_build_reg_cache(struct target *target)
        struct or1k_common *or1k = target_to_or1k(target);
        struct reg_cache **cache_p = register_get_last_cache_p(&target->reg_cache);
        struct reg_cache *cache = malloc(sizeof(struct reg_cache));
-       struct reg *reg_list = malloc((or1k->nb_regs) * sizeof(struct reg));
+       struct reg *reg_list = calloc(or1k->nb_regs, sizeof(struct reg));
        struct or1k_core_reg *arch_info =
                malloc((or1k->nb_regs) * sizeof(struct or1k_core_reg));
        struct reg_feature *feature;

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)