Patchwork [U-Boot,12/15] x86: Fix off-by-one error in do_elf_reloc_fixups()

login
register
mail settings
Submitter Simon Glass
Date Oct. 24, 2012, 4:04 a.m.
Message ID <1351051486-6980-13-git-send-email-sjg@chromium.org>
Download mbox | patch
Permalink /patch/193663/
State Accepted, archived
Delegated to: Simon Glass
Headers show

Comments

Simon Glass - Oct. 24, 2012, 4:04 a.m.
From: Duncan Laurie <dlaurie@chromium.org>

The use of post-increment with a do-while loop results in
the loop going one step too far when handling relocation fixups.

In about 1/100 cases this would cause it to hang.

Signed-off-by: Duncan Laurie <dlaurie@chromium.org>
Signed-off-by: Simon Glass <sjg@chromium.org>
---
 arch/x86/lib/relocate.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch

diff --git a/arch/x86/lib/relocate.c b/arch/x86/lib/relocate.c
index 200baab..c0b9b29 100644
--- a/arch/x86/lib/relocate.c
+++ b/arch/x86/lib/relocate.c
@@ -85,7 +85,7 @@  int do_elf_reloc_fixups(void)
 				*offset_ptr_ram += gd->reloc_off;
 			}
 		}
-	} while (re_src++ < re_end);
+	} while (++re_src < re_end);
 
 	return 0;
 }