memmove_wd: copy chunk down from big address if parameter to is larger than from
PATCH 1/1 memmove_wd: copy chunk down from big address if parameter to is larger than from
From: Sonic Zhang <[email protected]>
When watchdog is enabled, memmove_wd() always copy chunk up from small address. This damanges overlapped memory data if destination address is smaller than source address.
---
common/image.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
common/image.c +12 -2
@@ -485,12 +485,22 @@ void memmove_wd(void *to, void *from, size_t len, ulong chunksz)return ;#if defined(CONFIG_HW_WATCHDOG ) || defined(CONFIG_WATCHDOG ) +if (to > from) { + from += len; + to += len; + }while (len >0 ) {size_t tail = (len > chunksz) ? chunksz : len;WATCHDOG_RESET (); +if (to > from) { + to -= tail; + from -= tail; + }memmove (to, from, tail); - to += tail; - from += tail; +if (to < from) { + to += tail; + from += tail; + } len -= tail; }#else /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
Signature · 1 line
1.7.9.5
PATCH 1/1 memmove_wd: copy chunk down from big address if parameter to is larger than from
Quoted 11 lines · Sonic Zhang
From: Sonic Zhang <[email protected]>
When watchdog is enabled,
memmove_wd()always copy chunk up from small address. This damanges overlapped memory data if destination address is smaller than source address.Signed-off-by Sonic Zhang <[email protected]>---
common/image.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
Quoted 8 lines · Sonic Zhang
From: Sonic Zhang <[email protected]>
When watchdog is enabled,
memmove_wd()always copy chunk up from small address. This damanges overlapped memory data if destination address is smaller than source address.Signed-off-by Sonic Zhang <[email protected]>Acked-by Simon Glass <[email protected]>
Applied to u-boot/master, thanks!
Signature · 8 lines
Tom -------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 836 bytes Desc: Digital signature URL: <http://lists.denx.de/pipermail/u-boot/attachments/20150107/6bc8d713/attachment.pgp>