aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mm/swapfile.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/mm/swapfile.c b/mm/swapfile.c
index d1bd8d1e17bd30..2b3a2d85e350ba 100644
--- a/mm/swapfile.c
+++ b/mm/swapfile.c
@@ -3335,7 +3335,8 @@ static int __swap_duplicate(swp_entry_t entry, unsigned char usage)
} else
err = -ENOENT; /* unused swap entry */
- WRITE_ONCE(p->swap_map[offset], count | has_cache);
+ if (!err)
+ WRITE_ONCE(p->swap_map[offset], count | has_cache);
unlock_out:
unlock_cluster_or_swap_info(p, ci);