]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
erofs: fix handling kern_mount() failure
authorAl Viro <viro@zeniv.linux.org.uk>
Tue, 13 Feb 2024 03:44:11 +0000 (22:44 -0500)
committerSasha Levin <sashal@kernel.org>
Tue, 26 Mar 2024 22:19:40 +0000 (18:19 -0400)
[ Upstream commit 2c88c16dc20e88dd54d2f6f4d01ae1dce6cc9654 ]

if you have a variable that holds NULL or  a pointer to live struct mount,
do not shove ERR_PTR() into it - not if you later treat "not NULL" as
"holds a pointer to object".

Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
Stable-dep-of: 0f28be64d132 ("erofs: fix lockdep false positives on initializing erofs_pseudo_mnt")
Signed-off-by: Sasha Levin <sashal@kernel.org>
fs/erofs/fscache.c

index 87ff35bff8d5bb3acb8dbc4d79c07d1d018cba56..1052f75d1dfaec1eb87fdc066b00aba55f23aff9 100644 (file)
@@ -381,11 +381,12 @@ static int erofs_fscache_init_domain(struct super_block *sb)
                goto out;
 
        if (!erofs_pseudo_mnt) {
-               erofs_pseudo_mnt = kern_mount(&erofs_fs_type);
-               if (IS_ERR(erofs_pseudo_mnt)) {
-                       err = PTR_ERR(erofs_pseudo_mnt);
+               struct vfsmount *mnt = kern_mount(&erofs_fs_type);
+               if (IS_ERR(mnt)) {
+                       err = PTR_ERR(mnt);
                        goto out;
                }
+               erofs_pseudo_mnt = mnt;
        }
 
        domain->volume = sbi->volume;