Skip to content

Commit 788ee16

Browse files
fs/ntfs3: Fix root inode checking
Separate checking inode->i_op and inode itself. Reported-by: kernel test robot <lkp@intel.com> Reported-by: Dan Carpenter <error27@gmail.com> Link: https://lore.kernel.org/r/202302162319.bDJOuyfy-lkp@intel.com/ Signed-off-by: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
1 parent e43f6ec commit 788ee16

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

fs/ntfs3/super.c

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1347,12 +1347,21 @@ static int ntfs_fill_super(struct super_block *sb, struct fs_context *fc)
13471347
ref.low = cpu_to_le32(MFT_REC_ROOT);
13481348
ref.seq = cpu_to_le16(MFT_REC_ROOT);
13491349
inode = ntfs_iget5(sb, &ref, &NAME_ROOT);
1350-
if (IS_ERR(inode) || !inode->i_op) {
1350+
if (IS_ERR(inode)) {
13511351
err = PTR_ERR(inode);
13521352
ntfs_err(sb, "Failed to load root (%d).", err);
13531353
goto out;
13541354
}
13551355

1356+
/*
1357+
* Final check. Looks like this case should never occurs.
1358+
*/
1359+
if (!inode->i_op) {
1360+
err = -EINVAL;
1361+
ntfs_err(sb, "Failed to load root (%d).", err);
1362+
goto put_inode_out;
1363+
}
1364+
13561365
sb->s_root = d_make_root(inode);
13571366
if (!sb->s_root) {
13581367
err = -ENOMEM;

0 commit comments

Comments
 (0)