[PATCH 3.13 076/103] memblock, memhotplug: fix wrong type in memblock_find_in_range_node().

Kamal Mostafa kamal at canonical.com
Tue Sep 30 21:31:21 UTC 2014


3.13.11.8 -stable review patch.  If anyone has any objections, please let me know.

------------------

From: Tang Chen <tangchen at cn.fujitsu.com>

commit 0cfb8f0c3e21e36d4a6e472e4c419d58ba848698 upstream.

In memblock_find_in_range_node(), we defined ret as int.  But it should
be phys_addr_t because it is used to store the return value from
__memblock_find_range_bottom_up().

The bug has not been triggered because when allocating low memory near
the kernel end, the "int ret" won't turn out to be negative.  When we
started to allocate memory on other nodes, and the "int ret" could be
minus.  Then the kernel will panic.

A simple way to reproduce this: comment out the following code in
numa_init(),

        memblock_set_bottom_up(false);

and the kernel won't boot.

Reported-by: Xishi Qiu <qiuxishi at huawei.com>
Signed-off-by: Tang Chen <tangchen at cn.fujitsu.com>
Tested-by: Xishi Qiu <qiuxishi at huawei.com>
Signed-off-by: Andrew Morton <akpm at linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds at linux-foundation.org>
Signed-off-by: Kamal Mostafa <kamal at canonical.com>
---
 mm/memblock.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mm/memblock.c b/mm/memblock.c
index 53e477b..4ae6835 100644
--- a/mm/memblock.c
+++ b/mm/memblock.c
@@ -177,8 +177,7 @@ phys_addr_t __init_memblock memblock_find_in_range_node(phys_addr_t start,
 					phys_addr_t end, phys_addr_t size,
 					phys_addr_t align, int nid)
 {
-	int ret;
-	phys_addr_t kernel_end;
+	phys_addr_t kernel_end, ret;
 
 	/* pump up @end */
 	if (end == MEMBLOCK_ALLOC_ACCESSIBLE)
-- 
1.9.1





More information about the kernel-team mailing list