mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konstantin Komarov <almaz.alexandrovich@paragon-software.com>
To: <ntfs3@lists.linux.dev>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
	<linux-fsdevel@vger.kernel.org>,
	Dan Carpenter <error27@gmail.com>
Subject: [PATCH] fs/ntfs3: Fix root inode checking
Date: Mon, 20 Feb 2023 10:32:20 +0400	[thread overview]
Message-ID: <5de3e85e-3c8e-cc80-c825-481ac9f94f9a@paragon-software.com> (raw)

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


                 reply	other threads:[~2023-02-20  6:32 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5de3e85e-3c8e-cc80-c825-481ac9f94f9a@paragon-software.com \
    --to=almaz.alexandrovich@paragon-software.com \
    --cc=error27@gmail.com \
    --cc=linux-fsdevel@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ntfs3@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®