diff --git a/mm/swapfile.c b/mm/swapfile.c index a14257ac0476..2b8d9c3fbb47 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2713,9 +2713,8 @@ static struct swap_info_struct *alloc_swap_info(void) struct swap_info_struct *p; unsigned int type; int i; - unsigned int size = sizeof(*p) + nr_node_ids * sizeof(struct plist_node); - p = kvzalloc(size, GFP_KERNEL); + p = kvzalloc(struct_size(p, avail_lists, nr_node_ids), GFP_KERNEL); if (!p) return ERR_PTR(-ENOMEM);