From: Robert Hentosh Date: Tue, 30 May 2006 20:48:00 +0000 (+0200) Subject: [PATCH] x86_64: Fix off by one in bad_addr checking in find_e820_area X-Git-Tag: v2.6.17-rc6~76 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ca97c6131dac9f06b1856a95a2ec89d43844286;p=linux-2.6 [PATCH] x86_64: Fix off by one in bad_addr checking in find_e820_area From: Robert Hentosh Actually, we just stumbled on a different bug found in find_e820_area() in e820.c. The following code does not handle the edge condition correctly: while (bad_addr(&addr, size) && addr+size < ei->addr + ei->size) ; last = addr + size; if ( last > ei->addr + ei->size ) continue; The second statement in the while loop needs to be a <= b so that it is the logical negavite of the if (a > b) outside it. It needs to read: while (bad_addr(&addr, size) && addr+size <= ei->addr + ei->size) ; In the case that failed bad_addr was returning an address that is exactly size bellow the end of the e820 range. AK: Again together with the earlier avoid edma fix this fixes boot on a Dell PE6850/16GB Signed-off-by: Andi Kleen Signed-off-by: Linus Torvalds --- diff --git a/arch/x86_64/kernel/e820.c b/arch/x86_64/kernel/e820.c index 222b5b46d2..1ef6028f72 100644 --- a/arch/x86_64/kernel/e820.c +++ b/arch/x86_64/kernel/e820.c @@ -149,7 +149,7 @@ unsigned long __init find_e820_area(unsigned long start, unsigned long end, unsi addr = start; if (addr > ei->addr + ei->size) continue; - while (bad_addr(&addr, size) && addr+size < ei->addr + ei->size) + while (bad_addr(&addr, size) && addr+size <= ei->addr+ei->size) ; last = addr + size; if (last > ei->addr + ei->size)