* fs/ntfs/attrlist.c:126 ntfs_attrlist_entry_add() warn: variable dereferenced before check 'ni' (see line 122)
@ 2026-05-01 9:11 Dan Carpenter
2026-05-01 11:29 ` Namjae Jeon
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2026-05-01 9:11 UTC (permalink / raw)
To: oe-kbuild, Namjae Jeon
Cc: lkp, oe-kbuild-all, linux-kernel, Amir Goldstein,
Christoph Hellwig
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
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: fs/ntfs/attrlist.c:126 ntfs_attrlist_entry_add() warn: variable dereferenced before check 'ni' (see line 122)
2026-05-01 9:11 fs/ntfs/attrlist.c:126 ntfs_attrlist_entry_add() warn: variable dereferenced before check 'ni' (see line 122) Dan Carpenter
@ 2026-05-01 11:29 ` Namjae Jeon
0 siblings, 0 replies; 2+ messages in thread
From: Namjae Jeon @ 2026-05-01 11:29 UTC (permalink / raw)
To: Dan Carpenter
Cc: oe-kbuild, lkp, oe-kbuild-all, linux-kernel, Amir Goldstein,
Christoph Hellwig
On Fri, May 1, 2026 at 6:12 PM Dan Carpenter <error27@gmail.com> wrote:
>
> 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)
I will fix it.
Thanks for the report!
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-05-01 11:30 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-05-01 9:11 fs/ntfs/attrlist.c:126 ntfs_attrlist_entry_add() warn: variable dereferenced before check 'ni' (see line 122) Dan Carpenter
2026-05-01 11:29 ` Namjae Jeon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox