Signed-off-by: Alexander Stein <alexander.st...@systec-electronic.com>
---
 common/image.c |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/common/image.c b/common/image.c
index 6d8833e..da0fdd5 100644
--- a/common/image.c
+++ b/common/image.c
@@ -456,9 +456,14 @@ void memmove_wd (void *to, void *from, size_t len, ulong 
chunksz)
        while (len > 0) {
                size_t tail = (len > chunksz) ? chunksz : len;
                WATCHDOG_RESET ();
-               memmove (to, from, tail);
-               to += tail;
-               from += tail;
+               if (to <= from)
+               {
+                       memmove (to, from, tail);
+                       to += tail;
+                       from += tail;
+               } else {
+                       memmove (to + len - tail, from + len - tail, tail);
+               }
                len -= tail;
        }
 #else  /* !(CONFIG_HW_WATCHDOG || CONFIG_WATCHDOG) */
-- 
1.7.1

_______________________________________________
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot

Reply via email to