summaryrefslogtreecommitdiff
path: root/fs/ntfs3
diff options
context:
space:
mode:
authorKonstantin Komarov <almaz.alexandrovich@paragon-software.com>2023-02-20 09:39:35 +0400
committerKonstantin Komarov <almaz.alexandrovich@paragon-software.com>2023-03-27 17:44:37 +0400
commit788ee1605c2e9feed39c3a749fb3e47c6e15c1b9 (patch)
treeee6f231bae383ef31631201dd0caa68a860688c7 /fs/ntfs3
parente43f6ec224c1b428260e161f0300afbe2e1194fe (diff)
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>
Diffstat (limited to 'fs/ntfs3')
-rw-r--r--fs/ntfs3/super.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/ntfs3/super.c b/fs/ntfs3/super.c
index e0f78b306f15..5158dd31fd97 100644
--- a/fs/ntfs3/super.c
+++ b/fs/ntfs3/super.c
@@ -1347,12 +1347,21 @@ load_root:
ref.low = cpu_to_le32(MFT_REC_ROOT);
ref.seq = cpu_to_le16(MFT_REC_ROOT);
inode = ntfs_iget5(sb, &ref, &NAME_ROOT);
- if (IS_ERR(inode) || !inode->i_op) {
+ if (IS_ERR(inode)) {
err = PTR_ERR(inode);
ntfs_err(sb, "Failed to load root (%d).", err);
goto out;
}
+ /*
+ * Final check. Looks like this case should never occurs.
+ */
+ if (!inode->i_op) {
+ err = -EINVAL;
+ ntfs_err(sb, "Failed to load root (%d).", err);
+ goto put_inode_out;
+ }
+
sb->s_root = d_make_root(inode);
if (!sb->s_root) {
err = -ENOMEM;