[U-Boot] [PATCH] memmove_wd: Allow overlapping memory area

Alexander Stein alexander.stein at systec-electronic.com
Wed Jul 21 10:43:46 CEST 2010


Signed-off-by: Alexander Stein <alexander.stein at 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



More information about the U-Boot mailing list