Commit 94832d93 authored by Chengguang Xu's avatar Chengguang Xu Committed by Greg Kroah-Hartman
Browse files

staging: erofs: fix potential double iput in erofs_read_super()



Some error cases like failing from d_make_root() will
cause double iput because d_make_root() also does iput
in its error path.

Signed-off-by: default avatarChengguang Xu <cgxu519@gmx.com>
Reviewed-by: default avatarChao Yu <yuchao0@huawei.com>
Reviewed-by: default avatarGao Xiang <gaoxiang25@huawei.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 45a50ab1
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -421,13 +421,14 @@ static int erofs_read_super(struct super_block *sb,
		errln("rootino(nid %llu) is not a directory(i_mode %o)",
			ROOT_NID(sbi), inode->i_mode);
		err = -EINVAL;
		goto err_isdir;
		iput(inode);
		goto err_iget;
	}

	sb->s_root = d_make_root(inode);
	if (sb->s_root == NULL) {
		err = -ENOMEM;
		goto err_makeroot;
		goto err_iget;
	}

	/* save the device name to sbi */
@@ -453,10 +454,6 @@ static int erofs_read_super(struct super_block *sb,
	 */
err_devname:
	dput(sb->s_root);
err_makeroot:
err_isdir:
	if (sb->s_root == NULL)
		iput(inode);
err_iget:
#ifdef EROFS_FS_HAS_MANAGED_CACHE
	iput(sbi->managed_cache);