Re: [PATCH v5 14/19] mm, swap: cleanup swap entry management workflow
From: Andrew Morton
Date: Wed Jan 14 2026 - 17:29:28 EST
On Thu, 15 Jan 2026 00:53:41 +0800 Kairui Song <ryncsn@xxxxxxxxx> wrote:
> Is it convenient for you to squash this attached fix into this patch?
Done, below
> That's the two issues from Chris Mason and Lai Yi combined in a clean
> to apply format, only 3 lines change.
Let's cc them!
> There might be minor conflict by removing the WARN_ON in two following
> patches, but should be easy to resolve. I can send a v6 if that's
> troublesome.
All fixed up, thanks.
From: Kairui Song <kasong@xxxxxxxxxxx>
Subject: mm, swap: fix locking and leaking with hibernation snapshot releasing
Date: Thu, 15 Jan 2026 00:15:27 +0800
fix leak, per Chris Mason. Remove WARN_ON, per Lai Yi
Link: https://lkml.kernel.org/r/CAMgjq7AUz10uETVm8ozDWcB3XohkOqf0i33KGrAquvEVvfp5cg@xxxxxxxxxxxxxx
Signed-off-by: Kairui Song <kasong@xxxxxxxxxxx>
Cc: Lai Yi <yi1.lai@xxxxxxxxxxxxxxx>
Cc: Chris Mason <clm@xxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---
kernel/power/swap.c | 2 +-
mm/swapfile.c | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
--- a/kernel/power/swap.c~mm-swap-cleanup-swap-entry-management-workflow-fix
+++ a/kernel/power/swap.c
@@ -199,7 +199,7 @@ void free_all_swap_pages(int swap)
ext = rb_entry(node, struct swsusp_extent, node);
rb_erase(node, &swsusp_extents);
- for (offset = ext->start; offset < ext->end; offset++)
+ for (offset = ext->start; offset <= ext->end; offset++)
swap_free_hibernation_slot(swp_entry(swap, offset));
kfree(ext);
--- a/mm/swapfile.c~mm-swap-cleanup-swap-entry-management-workflow-fix
+++ a/mm/swapfile.c
@@ -2096,7 +2096,6 @@ void swap_free_hibernation_slot(swp_entr
ci = swap_cluster_lock(si, offset);
swap_entry_put_locked(si, ci, entry, 1);
- WARN_ON(swap_entry_swapped(si, entry));
swap_cluster_unlock(ci);
/* In theory readahead might add it to the swap cache by accident */
_