[PATCH 2/2] swap: free allocated page if swap_read fails

From: Minchan Kim
Date: Fri Jul 27 2018 - 04:17:01 EST


swap_readpage could fails by -ENOMEM. In this case, we should free
allocated page instantly. There is no reason to retry.

Signed-off-by: Minchan Kim <minchan@xxxxxxxxxx>
---
mm/memory.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mm/memory.c b/mm/memory.c
index 7206a634270b..8a5e304ffd91 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -2943,7 +2943,8 @@ int do_swap_page(struct vm_fault *vmf)
__SetPageSwapBacked(page);
set_page_private(page, entry.val);
lru_cache_add_anon(page);
- swap_readpage(page, true);
+ if (swap_readpage(page, true))
+ goto out_page;
}
} else {
page = swapin_readahead(entry, GFP_HIGHUSER_MOVABLE,
--
2.18.0.345.g5c9ce644c3-goog


--tThc/1wpZn/ma/RB--