Skip to content

Commit e08d5f5

Browse files
Kemeng Shiakpm00
authored andcommitted
mm: shmem: avoid unpaired folio_unlock() in shmem_swapin_folio()
Patch series "Some random fixes and cleanup to shmem", v3. This series contains some simple fixes and cleanup which are made during learning shmem. More details can be found in respective patches. This patch (of 5): If we get a folio from swap_cache_get_folio() successfully but encounter a failure before the folio is locked, we will unlock the folio which was not previously locked. Put the folio and set it to NULL when a failure occurs before the folio is locked to fix the issue. Link: https://lkml.kernel.org/r/[email protected] Link: https://lkml.kernel.org/r/[email protected] Fixes: 0583135 ("mm: shmem: fix potential data corruption during shmem swapin") Signed-off-by: Kemeng Shi <[email protected]> Reviewed-by: Baolin Wang <[email protected]> Reviewed-by: Kairui Song <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: kernel test robot <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent 8e1c496 commit e08d5f5

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

mm/shmem.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2335,6 +2335,8 @@ static int shmem_swapin_folio(struct inode *inode, pgoff_t index,
23352335
*/
23362336
split_order = shmem_split_large_entry(inode, index, swap, gfp);
23372337
if (split_order < 0) {
2338+
folio_put(folio);
2339+
folio = NULL;
23382340
error = split_order;
23392341
goto failed;
23402342
}

0 commit comments

Comments
 (0)