提交 7ca97c61 编写于 作者: R Robert Hentosh 提交者: Linus Torvalds

[PATCH] x86_64: Fix off by one in bad_addr checking in find_e820_area

From: Robert Hentosh <robert_hentosh@dell.com>

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: NAndi Kleen <ak@suse.de>
Signed-off-by: NLinus Torvalds <torvalds@osdl.org>
上级 0d015324
...@@ -149,7 +149,7 @@ unsigned long __init find_e820_area(unsigned long start, unsigned long end, unsi ...@@ -149,7 +149,7 @@ unsigned long __init find_e820_area(unsigned long start, unsigned long end, unsi
addr = start; addr = start;
if (addr > ei->addr + ei->size) if (addr > ei->addr + ei->size)
continue; 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; last = addr + size;
if (last > ei->addr + ei->size) if (last > ei->addr + ei->size)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册