linux-fsdevel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fs/ntfs3: Fix root inode checking
@ 2023-02-20  6:32 Konstantin Komarov
  0 siblings, 0 replies; only message in thread
From: Konstantin Komarov @ 2023-02-20  6:32 UTC (permalink / raw)
  To: ntfs3; +Cc: Linux Kernel Mailing List, linux-fsdevel, Dan Carpenter

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>
---
  fs/ntfs3/super.c | 11 ++++++++++-
  1 file changed, 10 insertions(+), 1 deletion(-)

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 @@ static int ntfs_fill_super(struct super_block 
*sb, struct fs_context *fc)
      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;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-02-20  6:32 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-20  6:32 [PATCH] fs/ntfs3: Fix root inode checking Konstantin Komarov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).