diff --git a/mm/swapfile.c b/mm/swapfile.c
index a14257ac0476c6b1eb3df753c89e14a2bf781e87..2b8d9c3fbb47fd7a5c2a711dad73c5889dfe0bb2 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);