Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

mm/sparse: guard the size of mem_section is power of 2

We usually have this check, while commit 2a3cb8baef71 ("mm/sparse: delete
old sparse_init and enable new one") missed to take it.

Link: https://lkml.kernel.org/r/20240416012559.4536-1-richard.weiyang@gmail.com
Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
Acked-by: Oscar Salvador <osalvador@suse.de>
Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>
Cc: "Mike Rapoport (IBM)" <rppt@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Wei Yang and committed by
Andrew Morton
122ff80e 5ec5aab7

+2
+2
mm/sparse.c
··· 560 560 unsigned long pnum_end, pnum_begin, map_count = 1; 561 561 int nid_begin; 562 562 563 + /* see include/linux/mmzone.h 'struct mem_section' definition */ 564 + BUILD_BUG_ON(!is_power_of_2(sizeof(struct mem_section))); 563 565 memblocks_present(); 564 566 565 567 pnum_begin = first_present_section_nr();