From mboxrd@z Thu Jan 1 00:00:00 1970 From: Xiao Guangrong Subject: [PATCH] e820: fix clip_to_limit() Date: Tue, 10 Nov 2009 04:04:57 +0800 Message-ID: <4AF875E9.4040807@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: "keir.fraser" Cc: Xiao Guangrong , xen-devel List-Id: xen-devel@lists.xenproject.org In clip_to_limit(), after memmove(&e820.map[i], &e820.map[i+1], ...), the original e820.map[i+1] become current e820.map[i] but the next loop count is i+1, so the original e820.map[i+1] will be skipped Actually, e820 is sorted form low to high by sanitize_e820_map(), so we can simply break the loop if we meet the item which overrun "limit" Signed-off-by: Xiao Guangrong diff -r 93bc06dd1161 -r 5e06f2790d93 xen/arch/x86/e820.c --- a/xen/arch/x86/e820.c Tue Nov 10 02:41:59 2009 +0800 +++ b/xen/arch/x86/e820.c Tue Nov 10 03:51:08 2009 +0800 @@ -389,6 +389,7 @@ (e820.nr_map - i - 1) * sizeof(struct e820entry)); e820.nr_map--; } + break; } if ( old_limit )