]> git.sur5r.net Git - openocd/commit
cfi: fix write_bank segfault with spansion flash on armv7m
authorAurelien Jacobs <aurel@gnuage.org>
Tue, 8 May 2012 18:53:18 +0000 (20:53 +0200)
committerSpencer Oliver <spen@spen-soft.co.uk>
Mon, 14 May 2012 09:30:18 +0000 (09:30 +0000)
commit9d31589d19b1c9c4cbde5c361c046d735c43c215
tree103a7e8b0b96587da5198fa6325f0839b8d52373
parente95f8d93f2ae92d7226be947ca5c963bf879c18e
cfi: fix write_bank segfault with spansion flash on armv7m

cfi_spansion_write_block() passes an arm_algorithm struct to
target_run_algorithm() which in turn calls armv7m_start_algorithm()
which expect an armv7m_algorithm struct.
As armv7m_algorithm is bigger than arm_algorithm, when
armv7m_start_algorithm() writes in the struct, it overrun the buffer,
writting junk on the stack, which latter on generates a segfault.

This patch ensure we use a properly sized armv7m_algorithm struct
when the target is an armv7m.

Change-Id: I4ab67c15ae4bb72454414a81b92a4231dcdb2239
Signed-off-by: Aurelien Jacobs <aurel@gnuage.org>
Reviewed-on: http://openocd.zylin.com/623
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/flash/nor/cfi.c