flash/nor/lpc2000: properly free working area used in get_lpc2000_part_id() 95/2695/2
authorPaul Fertser <fercerpav@gmail.com>
Sat, 4 Apr 2015 17:50:37 +0000 (20:50 +0300)
committerPaul Fertser <fercerpav@gmail.com>
Tue, 14 Apr 2015 11:36:57 +0000 (12:36 +0100)
The IAP working area needs to be freed here, just like in all the
other driver functions since an automatic local variable is used to
store a pointer to it.

This was reported by quitte (Jonas Meyer) on IRC as a strange totally
unrelated segfault after doing certain operations (leading to target
reset) from GDB. He has provided me with remote access to the specific
machine and configuration that exposed the issue, and after some
debugging it became apparent that a auto local variable (holding the
gdb connection pointer) gets overwritten somehow. Placing an
appropriate breakpoint just before the event and using a watchpoint
made the cause apparent: reset lead to freeing of all working areas,
and there was one holding a pointer to a variable that was auto local
in get_lpc2000_part_id().

Change-Id: I7e634d890135ca0f3b4b311e09e8385a03982bd6
Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Reviewed-on: http://openocd.zylin.com/2695
Tested-by: jenkins
src/flash/nor/lpc2000.c

index 18085432b9a1d1f95cc5ddc348c19eb0339f36ea..15d9eb81c5c4ff29324124199fd33455946195fe 100644 (file)
@@ -1207,6 +1207,9 @@ static int get_lpc2000_part_id(struct flash_bank *bank, uint32_t *part_id)
           firmwares, so ignore it. */
        lpc2000_iap_call(bank, iap_working_area, 54, param_table, result_table);
 
+       struct target *target = bank->target;
+       target_free_working_area(target, iap_working_area);
+
        /* If the result is zero, the command probably didn't work out. */
        if (result_table[0] == 0)
                return LPC2000_INVALID_COMMAND;

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)