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
__archive__
Paul Fertser 2015-04-04 20:50:37 +03:00
parent e51d591641
commit cf77040e1e
1 changed files with 3 additions and 0 deletions

View 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;