This is an automated email from Gerrit.

Paul Fertser (fercer...@gmail.com) just uploaded a new patch set to Gerrit, 
which you can find at http://openocd.zylin.com/2696

-- gerrit

commit c52aac0eecaa6110be7221ce48b7c71c3753b589
Author: Paul Fertser <fercer...@gmail.com>
Date:   Sun Apr 5 00:16:59 2015 +0300

    flash/nor/lpc2000: free allocated working area when target_write fails
    
    In some circumstances (e.g. inappropriate jtag clock)
    target_write_memory in lpc2000_iap_working_area_init might fail. The
    allocated working area should be freed inside
    lpc2000_iap_working_area_init in this error case.
    
    This was leading to a weird segfault due to stack corruption later
    when reset was executed.
    
    Reported by quitte (Jonas Meyer).
    
    Change-Id: Ia2ed42a9970a4d771727fd516a6eea88e9b859e2
    Signed-off-by: Paul Fertser <fercer...@gmail.com>

diff --git a/src/flash/nor/lpc2000.c b/src/flash/nor/lpc2000.c
index 389df68..1dea0b3 100644
--- a/src/flash/nor/lpc2000.c
+++ b/src/flash/nor/lpc2000.c
@@ -706,9 +706,11 @@ static int lpc2000_iap_working_area_init(struct flash_bank 
*bank, struct working
        }
 
        int retval = target_write_memory(target, (*iap_working_area)->address, 
4, 2, jump_gate);
-       if (retval != ERROR_OK)
+       if (retval != ERROR_OK) {
                LOG_ERROR("Write memory at address 0x%8.8" PRIx32 " failed 
(check work_area definition)",
                                (*iap_working_area)->address);
+               target_free_working_area(target, *iap_working_area);
+       }
 
        return retval;
 }

-- 

------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
OpenOCD-devel mailing list
OpenOCD-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/openocd-devel

Reply via email to