From: Zhang Yanfei Date: Tue, 5 Nov 2013 05:55:40 +0000 (+1100) Subject: mm-sparsemem-fix-a-bug-in-free_map_bootmem-when-config_sparsemem_vmemmap-v2 X-Git-Tag: next-20131105~2^2~242 X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=13d2f7910ca46234c7973065ad9a12cbcf027120;p=karo-tx-linux.git mm-sparsemem-fix-a-bug-in-free_map_bootmem-when-config_sparsemem_vmemmap-v2 v2: Fix a bug introduced in v1 patch. Thanks wanpeng! Signed-off-by: Zhang Yanfei Cc: Wen Congyang Cc: Tang Chen Cc: Toshi Kani Cc: Yasuaki Ishimatsu Cc: Yinghai Lu Cc: Yasunori Goto Cc: Andy Whitcroft Signed-off-by: Andrew Morton --- diff --git a/mm/sparse.c b/mm/sparse.c index 908c13435627..8cc7be0e9590 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -651,10 +651,11 @@ static void __kfree_section_memmap(struct page *memmap) static void free_map_bootmem(struct page *memmap) { unsigned long maps_section_nr, removing_section_nr, i; - unsigned long magic; + unsigned long magic, nr_pages; struct page *page = virt_to_page(memmap); - unsigned long nr_pages = get_order(sizeof(struct page) * - PAGES_PER_SECTION); + + nr_pages = PAGE_ALIGN(PAGES_PER_SECTION * sizeof(struct page)) + >> PAGE_SHIFT; for (i = 0; i < nr_pages; i++, page++) { magic = (unsigned long) page->lru.next;