From: Wei Yang Date: Tue, 16 Apr 2024 01:25:59 +0000 (+0000) Subject: mm/sparse: guard the size of mem_section is power of 2 X-Git-Tag: v6.10-rc1~105^2~113 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=122ff80e12b3aa586d702b7fb651a99d443e7777;p=thirdparty%2Flinux.git 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 Acked-by: Oscar Salvador Reviewed-by: Pasha Tatashin Cc: "Mike Rapoport (IBM)" Signed-off-by: Andrew Morton --- diff --git a/mm/sparse.c b/mm/sparse.c index 46e88549d1a6a..de40b2c734067 100644 --- a/mm/sparse.c +++ b/mm/sparse.c @@ -560,6 +560,8 @@ void __init sparse_init(void) unsigned long pnum_end, pnum_begin, map_count = 1; int nid_begin; + /* see include/linux/mmzone.h 'struct mem_section' definition */ + BUILD_BUG_ON(!is_power_of_2(sizeof(struct mem_section))); memblocks_present(); pnum_begin = first_present_section_nr();