@@ -1062,8 +1062,8 @@ static inline unsigned long early_pfn_to_nid(unsigned long pfn)
#error Allocator MAX_ORDER exceeds SECTION_SIZE
#endif
-#define pfn_to_section_nr(pfn) ((pfn) >> PFN_SECTION_SHIFT)
-#define section_nr_to_pfn(sec) ((sec) << PFN_SECTION_SHIFT)
+#define pfn_to_section_nr(pfn) ((unsigned long)(pfn) >> PFN_SECTION_SHIFT)
+#define section_nr_to_pfn(sec) ((unsigned long)(sec) << PFN_SECTION_SHIFT)
#define SECTION_ALIGN_UP(pfn) (((pfn) + PAGES_PER_SECTION - 1) & PAGE_SECTION_MASK)
#define SECTION_ALIGN_DOWN(pfn) ((pfn) & PAGE_SECTION_MASK)
@@ -528,9 +528,7 @@ static int __meminit __add_section(int nid, struct zone *zone,
int __ref __add_pages(int nid, struct zone *zone, unsigned long phys_start_pfn,
unsigned long nr_pages)
{
- unsigned long i;
- int err = 0;
- int start_sec, end_sec;
+ int err = 0, i, start_sec, end_sec;
struct vmem_altmap *altmap;
clear_zone_contiguous(zone);
section_nr_to_pfn() will silently accept an argument that is too small to contain a pfn. Cast the argument to an unsigned long, similar to PFN_PHYS(). Fix up pfn_to_section_nr() in the same way. This was discovered in __add_pages() when converting it to use an signed integer for the loop variable. Cc: Michal Hocko <mhocko@suse.com> Cc: Vlastimil Babka <vbabka@suse.cz> Cc: Johannes Weiner <hannes@cmpxchg.org> Cc: Logan Gunthorpe <logang@deltatee.com> Cc: Mel Gorman <mgorman@techsingularity.net> Cc: Andrew Morton <akpm@linux-foundation.org> Cc: Stephen Bates <stephen.bates@microsemi.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> --- include/linux/mmzone.h | 4 ++-- mm/memory_hotplug.c | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-)