Skip to contentSkip to conversation

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

PATCH Applied Wei Yang 3 participants 3 messages Apr 16, 2024

Subsystems (2)
lore
Share & tools
lore

Wei Yang

author
#0 lore raw

PATCH 1/1 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.

CC Pavel Tatashin <[email protected]>
---
 mm/sparse.c | 2 ++
 1 file changed, 2 insertions(+)
mm/sparse.c +2 -0
index aed0951b87fa..a7d92fe7be19 100644
@@ -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();
Signature · 1 line
2.34.1
Reviewed-by on v1 1/1
#2 lore raw
In reply to Wei Yang
Quoted 15 lines · Wei Yang

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

CC Pavel Tatashin <[email protected]>
---
 mm/sparse.c | 2 ++
 1 file changed, 2 insertions(+)
mm/sparse.c +0 -0
index aed0951b87fa..a7d92fe7be19 100644

mm/sparse.c void __init sparse_init(void) · line 564

Quoted 5 lines
mm/sparse.c +2 -0
@@ -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)));

Thanks,
Pasha