Skip to content

Commit 122ff80

Browse files
RichardWeiYangakpm00
authored andcommitted
mm/sparse: guard the size of mem_section is power of 2
We usually have this check, while commit 2a3cb8b ("mm/sparse: delete old sparse_init and enable new one") missed to take it. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Wei Yang <[email protected]> Acked-by: Oscar Salvador <[email protected]> Reviewed-by: Pasha Tatashin <[email protected]> Cc: "Mike Rapoport (IBM)" <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 5ec5aab commit 122ff80

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mm/sparse.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -560,6 +560,8 @@ void __init sparse_init(void)
560560
unsigned long pnum_end, pnum_begin, map_count = 1;
561561
int nid_begin;
562562

563+
/* see include/linux/mmzone.h 'struct mem_section' definition */
564+
BUILD_BUG_ON(!is_power_of_2(sizeof(struct mem_section)));
563565
memblocks_present();
564566

565567
pnum_begin = first_present_section_nr();

0 commit comments

Comments
 (0)