From: David Rientjes Date: Fri, 25 Feb 2011 09:06:39 +0000 (+0100) Subject: x86-64, NUMA: Fix size of numa_distance array X-Git-Tag: upstream/snapshot3+hdmi~11246^2~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=1f565a896ee139a70e1a16f74a4ec29707691b0b;p=platform%2Fadaptation%2Frenesas_rcar%2Frenesas_kernel.git x86-64, NUMA: Fix size of numa_distance array numa_distance should be sized like the SLIT, an NxN matrix where N is the highest node id + 1. This patch fixes the calculation to avoid overflowing the array on the subsequent iteration. -tj: The original patch used last index to calculate size. Yinghai pointed out it should be incremented so it is the number of elements instead of the last index to calculate the size of the table. Updated accordingly. Signed-off-by: David Rientjes Cc: Yinghai Lu Signed-off-by: Tejun Heo --- diff --git a/arch/x86/mm/numa_64.c b/arch/x86/mm/numa_64.c index cccc01d..7757d22 100644 --- a/arch/x86/mm/numa_64.c +++ b/arch/x86/mm/numa_64.c @@ -414,7 +414,8 @@ static int __init numa_alloc_distance(void) for_each_node_mask(i, nodes_parsed) cnt = i; - size = ++cnt * sizeof(numa_distance[0]); + cnt++; + size = cnt * cnt * sizeof(numa_distance[0]); phys = memblock_find_in_range(0, (u64)max_pfn_mapped << PAGE_SHIFT, size, PAGE_SIZE);