mm: shmem: avoid unpaired folio_unlock() in shmem_swapin_folio()
authorKemeng Shi <shikemeng@huaweicloud.com>
Fri, 16 May 2025 17:09:35 +0000 (01:09 +0800)
committerAndrew Morton <akpm@linux-foundation.org>
Sun, 1 Jun 2025 05:46:10 +0000 (22:46 -0700)
commite08d5f515613a9860bfee7312461a19f422adb5e
tree599e8c8b3cf85349c19aff507d9c58a9fb5d323e
parent8e1c4961f44be6172553c062d8f425a4a4357afa
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/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>
mm/shmem.c