From: Dan Carpenter <error27@gmail.com>
To: oe-kbuild@lists.linux.dev, Namjae Jeon <linkinjeon@kernel.org>
Cc: lkp@intel.com, oe-kbuild-all@lists.linux.dev,
linux-kernel@vger.kernel.org, Amir Goldstein <amir73il@gmail.com>,
Christoph Hellwig <hch@lst.de>
Subject: fs/ntfs/attrlist.c:126 ntfs_attrlist_entry_add() warn: variable dereferenced before check 'ni' (see line 122)
Date: Fri, 1 May 2026 12:11:57 +0300 [thread overview]
Message-ID: <202605011540.0FJWFGIn-lkp@intel.com> (raw)
tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head: 26fd6bff2c050196005312d1d306889220952a99
commit: 47503f989736d6c4c9f8bfca1c28d267473ccd4b ntfs: add Kconfig and Makefile
config: x86_64-randconfig-161-20260501 (https://download.01.org/0day-ci/archive/20260501/202605011540.0FJWFGIn-lkp@intel.com/config)
compiler: gcc-14 (Debian 14.2.0-19) 14.2.0
smatch: v0.5.0-9065-ge9cc34fd
If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Fixes: 47503f989736 ("ntfs: add Kconfig and Makefile")
| Reported-by: kernel test robot <lkp@intel.com>
| Reported-by: Dan Carpenter <error27@gmail.com>
| Closes: https://lore.kernel.org/r/202605011540.0FJWFGIn-lkp@intel.com/
New smatch warnings:
fs/ntfs/attrlist.c:126 ntfs_attrlist_entry_add() warn: variable dereferenced before check 'ni' (see line 122)
fs/ntfs/attrlist.c:126 ntfs_attrlist_entry_add() warn: variable dereferenced before check 'attr' (see line 122)
fs/ntfs/attrib.c:2807 ntfs_attr_open() warn: variable dereferenced before check 'ni' (see line 2804)
Old smatch warnings:
fs/ntfs/attrib.c:2115 ntfs_resident_attr_record_add() warn: variable dereferenced before check 'ni' (see line 2111)
fs/ntfs/attrib.c:2237 ntfs_non_resident_attr_record_add() warn: variable dereferenced before check 'ni' (see line 2232)
fs/ntfs/attrib.c:4951 ntfs_attr_remove() warn: variable dereferenced before check 'ni' (see line 4950)
vim +/ni +126 fs/ntfs/attrlist.c
495e90fa334828d Namjae Jeon 2026-02-13 112 int ntfs_attrlist_entry_add(struct ntfs_inode *ni, struct attr_record *attr)
495e90fa334828d Namjae Jeon 2026-02-13 113 {
495e90fa334828d Namjae Jeon 2026-02-13 114 struct attr_list_entry *ale;
495e90fa334828d Namjae Jeon 2026-02-13 115 __le64 mref;
495e90fa334828d Namjae Jeon 2026-02-13 116 struct ntfs_attr_search_ctx *ctx;
495e90fa334828d Namjae Jeon 2026-02-13 117 u8 *new_al;
495e90fa334828d Namjae Jeon 2026-02-13 118 int entry_len, entry_offset, err;
495e90fa334828d Namjae Jeon 2026-02-13 119 struct mft_record *ni_mrec;
495e90fa334828d Namjae Jeon 2026-02-13 120 u8 *old_al;
495e90fa334828d Namjae Jeon 2026-02-13 121
495e90fa334828d Namjae Jeon 2026-02-13 @122 ntfs_debug("Entering for inode 0x%llx, attr 0x%x.\n",
495e90fa334828d Namjae Jeon 2026-02-13 123 (long long) ni->mft_no,
^^^^^^^^^^
495e90fa334828d Namjae Jeon 2026-02-13 124 (unsigned int) le32_to_cpu(attr->type));
495e90fa334828d Namjae Jeon 2026-02-13 125
495e90fa334828d Namjae Jeon 2026-02-13 @126 if (!ni || !attr) {
^^^
Checked too late.
495e90fa334828d Namjae Jeon 2026-02-13 127 ntfs_debug("Invalid arguments.\n");
495e90fa334828d Namjae Jeon 2026-02-13 128 return -EINVAL;
495e90fa334828d Namjae Jeon 2026-02-13 129 }
495e90fa334828d Namjae Jeon 2026-02-13 130
495e90fa334828d Namjae Jeon 2026-02-13 131 ni_mrec = map_mft_record(ni);
495e90fa334828d Namjae Jeon 2026-02-13 132 if (IS_ERR(ni_mrec)) {
495e90fa334828d Namjae Jeon 2026-02-13 133 ntfs_debug("Invalid arguments.\n");
495e90fa334828d Namjae Jeon 2026-02-13 134 return -EIO;
495e90fa334828d Namjae Jeon 2026-02-13 135 }
495e90fa334828d Namjae Jeon 2026-02-13 136
495e90fa334828d Namjae Jeon 2026-02-13 137 mref = MK_LE_MREF(ni->mft_no, le16_to_cpu(ni_mrec->sequence_number));
495e90fa334828d Namjae Jeon 2026-02-13 138 unmap_mft_record(ni);
495e90fa334828d Namjae Jeon 2026-02-13 139
495e90fa334828d Namjae Jeon 2026-02-13 140 if (ni->nr_extents == -1)
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
next reply other threads:[~2026-05-01 9:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-01 9:11 Dan Carpenter [this message]
2026-05-01 11:29 ` fs/ntfs/attrlist.c:126 ntfs_attrlist_entry_add() warn: variable dereferenced before check 'ni' (see line 122) Namjae Jeon
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=202605011540.0FJWFGIn-lkp@intel.com \
--to=error27@gmail.com \
--cc=amir73il@gmail.com \
--cc=hch@lst.de \
--cc=linkinjeon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@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