summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVadim Bendebury <vbendeb@chromium.org>2015-03-26 13:35:23 -0700
committerPatrick Georgi <pgeorgi@google.com>2015-04-22 08:50:41 +0200
commit801aa7c355702efe2a6e505d59431980099a1f14 (patch)
tree4f3fe2a4c66f6114349fadd9b5d664ae4dfac5e9
parentee426cf54eea43b8fb5194abe948f8e00d4f4b4c (diff)
downloadcoreboot-801aa7c355702efe2a6e505d59431980099a1f14.tar.xz
libpayload: fix a mips memmove() bug
size_t is an unsigned type and as such is a bad choice for a counting down loop counter. BRANCH=all BUG=none TEST=editing cli command line does not cause hangs any more Change-Id: I0502553b5e2143052345edeb205a01558fccd9b8 Signed-off-by: Patrick Georgi <pgeorgi@chromium.org> Original-Commit-Id: 1c171f739497fcd26589976676ab94b23cd7ee8b Original-Change-Id: I4aa38379ac356114fc91a32cced2fa45a00a09d6 Original-Signed-off-by: Vadim Bendebury <vbendeb@chromium.org> Original-Reviewed-on: https://chromium-review.googlesource.com/262714 Original-Reviewed-by: Ionela Voinescu <ionela.voinescu@imgtec.com> Original-Tested-by: Ionela Voinescu <ionela.voinescu@imgtec.com> Original-Reviewed-by: David Hendricks <dhendrix@chromium.org> Reviewed-on: http://review.coreboot.org/9891 Tested-by: build bot (Jenkins) Reviewed-by: Stefan Reinauer <stefan.reinauer@coreboot.org>
-rw-r--r--payloads/libpayload/arch/mips/string.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/payloads/libpayload/arch/mips/string.c b/payloads/libpayload/arch/mips/string.c
index 0563cf82ac..6326d15994 100644
--- a/payloads/libpayload/arch/mips/string.c
+++ b/payloads/libpayload/arch/mips/string.c
@@ -47,11 +47,10 @@ void *memmove(void *dest, const void *src, size_t n)
if ((src < dest) && (dest - src < n)) {
u8 *ptr_d = dest;
const u8 *ptr_s = src;
- size_t i;
/* copy backwards */
- for (i = n - 1; i >= 0; i--)
- ptr_d[i] = ptr_s[i];
+ while (n--)
+ ptr_d[n] = ptr_s[n];
return dest;
}