]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
mm: shmem: avoid unpaired folio_unlock() in shmem_swapin_folio()
authorKemeng Shi <shikemeng@huaweicloud.com>
Mon, 23 Mar 2026 09:37:35 +0000 (02:37 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 25 Mar 2026 10:08:56 +0000 (11:08 +0100)
commit1be8e41962f1f695ebeec6eb847d314b60cb2c4b
treebbcf52d4306d5adac9bbf2a492a6f94ddbf7c5b7
parentb0e49178f2ed12f4ed5fc88f8d295f1d4f69e728
mm: shmem: avoid unpaired folio_unlock() in shmem_swapin_folio()

commit e08d5f515613a9860bfee7312461a19f422adb5e upstream.

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/20250516170939.965736-1-shikemeng@huaweicloud.com
Link: https://lkml.kernel.org/r/20250516170939.965736-2-shikemeng@huaweicloud.com
Fixes: 058313515d5a ("mm: shmem: fix potential data corruption during shmem swapin")
Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com>
Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com>
Reviewed-by: Kairui Song <kasong@tencent.com>
Cc: Hugh Dickins <hughd@google.com>
Cc: kernel test robot <oliver.sang@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
[ hughd: removed series cover letter comments ]
Signed-off-by: Hugh Dickins <hughd@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
mm/shmem.c