diff mbox series

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

Message ID 20240416012559.4536-1-richard.weiyang@gmail.com (mailing list archive)
State New
Headers show
Series mm/sparse: guard the size of mem_section is power of 2 | expand

Commit Message

Wei Yang April 16, 2024, 1:25 a.m. UTC
We usually have this check, while commit 2a3cb8baef71 ("mm/sparse:
delete old sparse_init and enable new one") missed to take it.

Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
CC: Pavel Tatashin <pasha.tatashin@oracle.com>
---
 mm/sparse.c | 2 ++
 1 file changed, 2 insertions(+)

Comments

Oscar Salvador April 16, 2024, 4:55 a.m. UTC | #1
On Tue, Apr 16, 2024 at 01:25:59AM +0000, Wei Yang wrote:
> We usually have this check, while commit 2a3cb8baef71 ("mm/sparse:
> delete old sparse_init and enable new one") missed to take it.
> 
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Pavel Tatashin <pasha.tatashin@oracle.com>

Acked-by: Oscar Salvador <osalvador@suse.de>
Pasha Tatashin April 16, 2024, 3:20 p.m. UTC | #2
On Mon, Apr 15, 2024 at 9:26 PM Wei Yang <richard.weiyang@gmail.com> wrote:
>
> We usually have this check, while commit 2a3cb8baef71 ("mm/sparse:
> delete old sparse_init and enable new one") missed to take it.
>
> Signed-off-by: Wei Yang <richard.weiyang@gmail.com>
> CC: Pavel Tatashin <pasha.tatashin@oracle.com>
> ---
>  mm/sparse.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/mm/sparse.c b/mm/sparse.c
> index aed0951b87fa..a7d92fe7be19 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)));

Reviewed-by: Pasha Tatashin <pasha.tatashin@soleen.com>

Thanks,
Pasha
diff mbox series

Patch

diff --git a/mm/sparse.c b/mm/sparse.c
index aed0951b87fa..a7d92fe7be19 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();