diff options
-rw-r--r-- | common/image.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/common/image.c b/common/image.c index b75a5ce..e691a51 100644 --- a/common/image.c +++ b/common/image.c @@ -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) */ |