diff --git a/mm/swapfile.c b/mm/swapfile.c index e47a21e64764..03d2ce288d83 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c @@ -2954,6 +2954,10 @@ static unsigned long read_swap_header(struct swap_info_struct *p, maxpages = swp_offset(pte_to_swp_entry( swp_entry_to_pte(swp_entry(0, ~0UL)))) + 1; last_page = swap_header->info.last_page; + if (!last_page) { + pr_warn("Empty swap-file\n"); + return 0; + } if (last_page > maxpages) { pr_warn("Truncating oversized swap area, only using %luk out of %luk\n", maxpages << (PAGE_SHIFT - 10),