ntfs: fix variable dereferenced before check ni and attr in ntfs_attrlist_entry_add()

Smatch warnings:

ntfs_attrlist_entry_add() warn: variable dereferenced before check 'ni'
ntfs_attrlist_entry_add() warn: variable dereferenced before check 'attr'

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>
This commit is contained in:
Namjae Jeon 2026-05-01 21:10:38 +09:00
parent 66edb901bf
commit d3894e4e09

View File

@ -119,15 +119,14 @@ int ntfs_attrlist_entry_add(struct ntfs_inode *ni, struct attr_record *attr)
struct mft_record *ni_mrec;
u8 *old_al;
ntfs_debug("Entering for inode 0x%llx, attr 0x%x.\n",
(long long) ni->mft_no,
(unsigned int) le32_to_cpu(attr->type));
if (!ni || !attr) {
ntfs_debug("Invalid arguments.\n");
return -EINVAL;
}
ntfs_debug("Entering for inode 0x%llx, attr 0x%x.\n",
ni->mft_no, (unsigned int) le32_to_cpu(attr->type));
ni_mrec = map_mft_record(ni);
if (IS_ERR(ni_mrec)) {
ntfs_debug("Invalid arguments.\n");