mm/memory_hotplug.c: fix overflow in test_pages_in_a_zone()
Subsystems (2)
[email protected]
maintainerPATCH 79/124 mm/memory_hotplug.c: fix overflow in test_pages_in_a_zone()
From: zhong jiang <[email protected]>
Subject: mm/memory_hotplug.c: fix overflow in test_pages_in_a_zone()
When mainline introduced a96dfddbcc04 ("base/memory, hotplug: fix a kernel oops in show_valid_zones()"), it obtained the valid start and end pfn from the given pfn range. The valid start pfn can fix the actual issue, but it introduced another issue. The valid end pfn will may exceed the given end_pfn.
Although the incorrect overflow will not result in actual problem at present, but I think it need to be fixed.
[[email protected]: remove assumption that end_pfn is aligned by MAX_ORDER_NR_PAGES]
Fixes a96dfddbcc04 ("base/memory, hotplug: fix a kernel oops in show_valid_zones()")
Signed-off-by zhong jiang <[email protected]>
Signed-off-by Toshi Kani <[email protected]>
Cc Vlastimil Babka <[email protected]>
Cc Mel Gorman <[email protected]>
Signed-off-by Andrew Morton <[email protected]>
---
mm/memory_hotplug.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
mm/memory_hotplug.c renamed from mm/memory_hotplug.c~mm-fix-a-overflow-in-test_pages_in_a_zone +2 -2
@@ -1509,7 +1509,7 @@ int test_pages_in_a_zone(unsigned long swhile ((i <MAX_ORDER_NR_PAGES ) && !pfn_valid_within (pfn + i)) i++; -if (i ==MAX_ORDER_NR_PAGES ) +if (i ==MAX_ORDER_NR_PAGES || pfn + i >= end_pfn)continue ; page =pfn_to_page (pfn + i);if (zone &&page_zone (page) != zone)
@@ -1523,7 +1523,7 @@ int test_pages_in_a_zone(unsigned long sif (zone) { *valid_start = start; - *valid_end = end; + *valid_end =min (end, end_pfn);return 1 ; }else {return 0 ;
_