[PATCH] shmem_swapin_page(): fix error processing for get_swap_device()
From: Huang Ying
Date: Mon Aug 02 2021 - 22:51:16 EST
Firstly, "-" is missing before the error code. Secondly, EINVAL isn't
the proper error code for the race condition. EEXIST is used in
shmem_swapin_page() for that. So the error code is changed to EEXIST
too.
Link: https://lkml.kernel.org/r/20210723080000.93953-1-ying.huang@xxxxxxxxx
Fixes: 2efa33fc7f6e ("mm/shmem: fix shmem_swapin() race with swapoff")
Signed-off-by: "Huang, Ying" <ying.huang@xxxxxxxxx>
Cc: Miaohe Lin <linmiaohe@xxxxxxxxxx>
Cc: Hugh Dickins <hughd@xxxxxxxxxx>
Cc: Johannes Weiner <hannes@xxxxxxxxxxx>
Cc: Michal Hocko <mhocko@xxxxxxxx>
Cc: Joonsoo Kim <iamjoonsoo.kim@xxxxxxx>
Cc: Matthew Wilcox <willy@xxxxxxxxxxxxx>
Cc: Minchan Kim <minchan@xxxxxxxxxx>
Cc: David Hildenbrand <david@xxxxxxxxxx>
---
mm/shmem.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/mm/shmem.c b/mm/shmem.c
index dcc07d14162e..ba925baa4404 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -1711,8 +1711,8 @@ static int shmem_swapin_page(struct inode *inode, pgoff_t index,
/* Prevent swapoff from happening to us. */
si = get_swap_device(swap);
if (!si) {
- error = EINVAL;
- goto failed;
+ error = -EEXIST;
+ goto unlock;
}
/* Look it up and read it in.. */
page = lookup_swap_cache(swap, NULL, 0);
--
2.30.2