From: Hyunchul Lee <hyc.lee@gmail.com>
To: Ethan Tidmore <ethantidmore06@gmail.com>
Cc: linkinjeon@kernel.org, linux-fsdevel@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/3] ntfs: Place check before dereference
Date: Fri, 27 Feb 2026 11:32:14 +0900 [thread overview]
Message-ID: <aaECLoLaA3rXaAqf@hyunchul-PC02> (raw)
In-Reply-To: <20260226160906.7175-2-ethantidmore06@gmail.com>
On Thu, Feb 26, 2026 at 10:09:04AM -0600, Ethan Tidmore wrote:
> The variable ni has the possiblity of being null and is checked for it
> but, only after it was dereferenced in a log message.
>
> Put check before dereference.
>
> Detected by Smatch:
> 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)
>
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
Looks good to me. Thank for the patch
Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>
> ---
> fs/ntfs/attrib.c | 12 ++++++------
> 1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/fs/ntfs/attrib.c b/fs/ntfs/attrib.c
> index e8285264f619..e260540eb7c5 100644
> --- a/fs/ntfs/attrib.c
> +++ b/fs/ntfs/attrib.c
> @@ -2108,13 +2108,13 @@ int ntfs_resident_attr_record_add(struct ntfs_inode *ni, __le32 type,
> int err, offset;
> struct ntfs_inode *base_ni;
>
> + if (!ni || (!name && name_len))
> + return -EINVAL;
> +
> ntfs_debug("Entering for inode 0x%llx, attr 0x%x, flags 0x%x.\n",
> (long long) ni->mft_no, (unsigned int) le32_to_cpu(type),
> (unsigned int) le16_to_cpu(flags));
>
> - if (!ni || (!name && name_len))
> - return -EINVAL;
> -
> err = ntfs_attr_can_be_resident(ni->vol, type);
> if (err) {
> if (err == -EPERM)
> @@ -2229,14 +2229,14 @@ static int ntfs_non_resident_attr_record_add(struct ntfs_inode *ni, __le32 type,
> struct ntfs_inode *base_ni;
> int err, offset;
>
> + if (!ni || dataruns_size <= 0 || (!name && name_len))
> + return -EINVAL;
> +
> ntfs_debug("Entering for inode 0x%llx, attr 0x%x, lowest_vcn %lld, dataruns_size %d, flags 0x%x.\n",
> (long long) ni->mft_no, (unsigned int) le32_to_cpu(type),
> (long long) lowest_vcn, dataruns_size,
> (unsigned int) le16_to_cpu(flags));
>
> - if (!ni || dataruns_size <= 0 || (!name && name_len))
> - return -EINVAL;
> -
> err = ntfs_attr_can_be_non_resident(ni->vol, type);
> if (err) {
> if (err == -EPERM)
> --
> 2.53.0
>
--
Thanks,
Hyunchul
next prev parent reply other threads:[~2026-02-27 2:32 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-26 16:09 [PATCH 0/3] ntfs: Bug fixes for attrib.c Ethan Tidmore
2026-02-26 16:09 ` [PATCH 1/3] ntfs: Place check before dereference Ethan Tidmore
2026-02-27 2:32 ` Hyunchul Lee [this message]
2026-02-26 16:09 ` [PATCH 2/3] ntfs: Add missing error code Ethan Tidmore
2026-02-27 2:37 ` Hyunchul Lee
2026-02-26 16:09 ` [PATCH 3/3] ntfs: Fix possible deadlock Ethan Tidmore
2026-02-27 2:38 ` Hyunchul Lee
2026-02-27 9:44 ` [PATCH 0/3] ntfs: Bug fixes for attrib.c 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=aaECLoLaA3rXaAqf@hyunchul-PC02 \
--to=hyc.lee@gmail.com \
--cc=ethantidmore06@gmail.com \
--cc=linkinjeon@kernel.org \
--cc=linux-fsdevel@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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