Skip to content

Commit 594ec2a

Browse files
Kemeng Shiakpm00
authored andcommitted
mm: shmem: add missing shmem_unacct_size() in __shmem_file_setup()
We will miss shmem_unacct_size() when is_idmapped_mnt() returns a failure. Move is_idmapped_mnt() before shmem_acct_size() to fix the issue. Link: https://lkml.kernel.org/r/20250516170939.965736-3-shikemeng@huaweicloud.com Fixes: 7a80e5b ("shmem: support idmapped mounts for tmpfs") Signed-off-by: Kemeng Shi <shikemeng@huaweicloud.com> Reviewed-by: Baolin Wang <baolin.wang@linux.alibaba.com> Cc: Hugh Dickins <hughd@google.com> Cc: Kairui Song <kasong@tencent.com> Cc: kernel test robot <oliver.sang@intel.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent e08d5f5 commit 594ec2a

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

mm/shmem.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5812,12 +5812,12 @@ static struct file *__shmem_file_setup(struct vfsmount *mnt, const char *name,
58125812
if (size < 0 || size > MAX_LFS_FILESIZE)
58135813
return ERR_PTR(-EINVAL);
58145814

5815-
if (shmem_acct_size(flags, size))
5816-
return ERR_PTR(-ENOMEM);
5817-
58185815
if (is_idmapped_mnt(mnt))
58195816
return ERR_PTR(-EINVAL);
58205817

5818+
if (shmem_acct_size(flags, size))
5819+
return ERR_PTR(-ENOMEM);
5820+
58215821
inode = shmem_get_inode(&nop_mnt_idmap, mnt->mnt_sb, NULL,
58225822
S_IFREG | S_IRWXUGO, 0, flags);
58235823
if (IS_ERR(inode)) {

0 commit comments

Comments
 (0)