]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
ntfs: fix variable dereferenced before check ni in ntfs_attr_open()
authorNamjae Jeon <linkinjeon@kernel.org>
Wed, 6 May 2026 11:36:37 +0000 (20:36 +0900)
committerNamjae Jeon <linkinjeon@kernel.org>
Fri, 8 May 2026 14:51:05 +0000 (23:51 +0900)
Smatch warnings:
 ntfs_attr_open() warn: variable dereferenced before check 'ni'

Moves the ntfs_debug() call after the NULL pointer checks to ensure safe
access to the structure members.

Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Namjae Jeon <linkinjeon@kernel.org>
fs/ntfs/attrib.c

index 7ab3571cc5f953b7456985ab2e41573583bbd8f4..d60d0c686718f428e194e43ea783dcb69f6ca0f3 100644 (file)
@@ -2913,12 +2913,12 @@ int ntfs_attr_open(struct ntfs_inode *ni, const __le32 type,
        struct ntfs_inode *base_ni;
        int err;
 
-       ntfs_debug("Entering for inode %lld, attr 0x%x.\n",
-                       (unsigned long long)ni->mft_no, type);
-
        if (!ni || !ni->vol)
                return -EINVAL;
 
+       ntfs_debug("Entering for inode %lld, attr 0x%x.\n",
+                       ni->mft_no, type);
+
        if (NInoAttr(ni))
                base_ni = ni->ext.base_ntfs_ino;
        else