Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753912Ab2HBGCi (ORCPT ); Thu, 2 Aug 2012 02:02:38 -0400 Received: from cn.fujitsu.com ([222.73.24.84]:49081 "EHLO song.cn.fujitsu.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1753373Ab2HBGBg (ORCPT ); Thu, 2 Aug 2012 02:01:36 -0400 X-IronPort-AV: E=Sophos;i="4.77,698,1336320000"; d="scan'208";a="5534643" From: Lai Jiangshan 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 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> X-Mailer: git-send-email 1.7.4.4 In-Reply-To: <1343887288-8866-1-git-send-email-laijs@cn.fujitsu.com> References: <1343887288-8866-1-git-send-email-laijs@cn.fujitsu.com> X-MIMETrack: Itemize by SMTP Server on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/08/02 14:02:05, Serialize by Router on mailserver/fnst(Release 8.5.3|September 15, 2011) at 2012/08/02 14:02:06, Serialize complete at 2012/08/02 14:02:06 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1441 Lines: 42 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 from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/