fs/ntfs3: Fix null-ptr-deref on inode->i_op in ntfs_lookup()
[platform/kernel/linux-starfive.git] / fs / ntfs3 / namei.c
index bc22cc3..7760aed 100644 (file)
@@ -86,6 +86,16 @@ static struct dentry *ntfs_lookup(struct inode *dir, struct dentry *dentry,
                __putname(uni);
        }
 
+       /*
+        * Check for a null pointer
+        * If the MFT record of ntfs inode is not a base record, inode->i_op can be NULL.
+        * This causes null pointer dereference in d_splice_alias().
+        */
+       if (!IS_ERR(inode) && inode->i_op == NULL) {
+               iput(inode);
+               inode = ERR_PTR(-EINVAL);
+       }
+
        return d_splice_alias(inode, dentry);
 }