The patch titled Subject: mm/memory_hotplug.c: check start_pfn in test_pages_in_a_zone() has been added to the -mm tree. Its filename is mm-memory_hotplugc-check-start_pfn-in-test_pages_in_a_zone.patch This patch should soon appear at http://ozlabs.org/~akpm/mmots/broken-out/mm-memory_hotplugc-check-start_pfn-in-test_pages_in_a_zone.patch and later at http://ozlabs.org/~akpm/mmotm/broken-out/mm-memory_hotplugc-check-start_pfn-in-test_pages_in_a_zone.patch Before you just go and hit "reply", please: a) Consider who else should be cc'ed b) Prefer to cc a suitable mailing list as well c) Ideally: find the original patch on the mailing list and do a reply-to-all to that, adding suitable additional cc's *** Remember to use Documentation/SubmitChecklist when testing your code *** The -mm tree is included into linux-next and is updated there every 3-4 working days ------------------------------------------------------ From: Toshi Kani <toshi.kani@xxxxxxx> Subject: mm/memory_hotplug.c: check start_pfn in test_pages_in_a_zone() test_pages_in_a_zone() does not check 'start_pfn' when it is aligned by section since 'sec_end_pfn' is set equal to 'pfn'. Since this function is called for testing the range of a sysfs memory file, 'start_pfn' is always aligned by section. Fix it by properly setting 'sec_end_pfn' to the next section pfn. Also make sure that this function returns 1 only when the range belongs to a zone. Link: http://lkml.kernel.org/r/20170127222149.30893-2-toshi.kani@xxxxxxx Signed-off-by: Toshi Kani <toshi.kani@xxxxxxx> Cc: Andrew Banman <abanman@xxxxxxx> Cc: Reza Arbab <arbab@xxxxxxxxxxxxxxxxxx> Cc: Greg KH <greg@xxxxxxxxx> Cc: <stable@xxxxxxxxxxxxxxx> [4.4+] Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx> --- mm/memory_hotplug.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff -puN mm/memory_hotplug.c~mm-memory_hotplugc-check-start_pfn-in-test_pages_in_a_zone mm/memory_hotplug.c --- a/mm/memory_hotplug.c~mm-memory_hotplugc-check-start_pfn-in-test_pages_in_a_zone +++ a/mm/memory_hotplug.c @@ -1483,7 +1483,7 @@ bool is_mem_section_removable(unsigned l } /* - * Confirm all pages in a range [start, end) is belongs to the same zone. + * Confirm all pages in a range [start, end) belong to the same zone. */ int test_pages_in_a_zone(unsigned long start_pfn, unsigned long end_pfn) { @@ -1491,9 +1491,9 @@ int test_pages_in_a_zone(unsigned long s struct zone *zone = NULL; struct page *page; int i; - for (pfn = start_pfn, sec_end_pfn = SECTION_ALIGN_UP(start_pfn); + for (pfn = start_pfn, sec_end_pfn = SECTION_ALIGN_UP(start_pfn + 1); pfn < end_pfn; - pfn = sec_end_pfn + 1, sec_end_pfn += PAGES_PER_SECTION) { + pfn = sec_end_pfn, sec_end_pfn += PAGES_PER_SECTION) { /* Make sure the memory section is present first */ if (!present_section_nr(pfn_to_section_nr(pfn))) continue; @@ -1512,7 +1512,11 @@ int test_pages_in_a_zone(unsigned long s zone = page_zone(page); } } - return 1; + + if (zone) + return 1; + else + return 0; } /* _ Patches currently in -mm which might be from toshi.kani@xxxxxxx are mm-memory_hotplugc-check-start_pfn-in-test_pages_in_a_zone.patch base-memory-hotplug-fix-a-kernel-oops-in-show_valid_zones.patch -- To unsubscribe from this list: send the line "unsubscribe mm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html