From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from psmtp.com (na3sys010amx167.postini.com [74.125.245.167]) by kanga.kvack.org (Postfix) with SMTP id 07BD46B005A for ; Thu, 2 Aug 2012 02:01:52 -0400 (EDT) From: Lai Jiangshan Subject: [RFC PATCH 22/23 V2] memblock: compare current_limit with end variable at memblock_find_in_range_node() Date: Thu, 2 Aug 2012 14:01:27 +0800 Message-Id: <1343887288-8866-23-git-send-email-laijs@cn.fujitsu.com> In-Reply-To: <1343887288-8866-1-git-send-email-laijs@cn.fujitsu.com> References: <1343887288-8866-1-git-send-email-laijs@cn.fujitsu.com> Sender: owner-linux-mm@kvack.org List-ID: To: Mel Gorman , linux-kernel@vger.kernel.org Cc: Yasuaki Ishimatsu , Lai Jiangshan , Tejun Heo , Andrew Morton , Ingo Molnar , Gavin Shan , Yinghai Lu , linux-mm@kvack.org From: Yasuaki Ishimatsu memblock_find_in_range_node() does not compare memblock.current_limit with end variable. Thus even if memblock.current_limit is smaller than end variable, the function allocates memory address that is bigger than memblock.current_limit. The patch adds the check to "memblock_find_in_range_node()" Signed-off-by: Yasuaki Ishimatsu Signed-off-by: Lai Jiangshan --- mm/memblock.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/mm/memblock.c b/mm/memblock.c index 663b805..ce7fcb6 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -99,11 +99,12 @@ phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t start, phys_addr_t align, int nid) { phys_addr_t this_start, this_end, cand; + phys_addr_t current_limit = memblock.current_limit; u64 i; /* pump up @end */ - if (end == MEMBLOCK_ALLOC_ACCESSIBLE) - end = memblock.current_limit; + if ((end == MEMBLOCK_ALLOC_ACCESSIBLE) || (end > current_limit)) + end = current_limit; /* avoid allocating the first page */ start = max_t(phys_addr_t, start, PAGE_SIZE); -- 1.7.1 -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org