aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Fertser <fercerpav@gmail.com>2015-04-04 20:50:37 +0300
committerPaul Fertser <fercerpav@gmail.com>2015-04-14 12:36:57 +0100
commitcf77040e1e435b9bd6e1d35cd5fc6ad874703d16 (patch)
tree34bd0d655d2184bb12d3f21d67b0e8ab05b001cb
parente51d591641c9a9cd0af9c4c2200d7051c4a88ef0 (diff)
flash/nor/lpc2000: properly free working area used in get_lpc2000_part_id()
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
-rw-r--r--src/flash/nor/lpc2000.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/flash/nor/lpc2000.c b/src/flash/nor/lpc2000.c
index 18085432..15d9eb81 100644
--- a/src/flash/nor/lpc2000.c
+++ b/src/flash/nor/lpc2000.c
@@ -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;