The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Hyunchul Lee <hyc.lee@gmail.com>
To: Ethan Tidmore <ethantidmore06@gmail.com>
Cc: Namjae Jeon <linkinjeon@kernel.org>,
	linux-fsdevel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ntfs: Fix null pointer dereference
Date: Thu, 26 Feb 2026 11:32:06 +0900	[thread overview]
Message-ID: <aZ-wphvo8fGvJEWY@hyunchul-PC02> (raw)
In-Reply-To: <20260225222453.1962678-1-ethantidmore06@gmail.com>

On Wed, Feb 25, 2026 at 04:24:53PM -0600, Ethan Tidmore wrote:
> The variable ctx can be null and once confirmed to be null in its error
> path goes to label err_out. Once there it can be immediately dereferenced
> by the function ntfs_attr_put_search_ctx() which has no null pointer check.
> 
> Detected by Smatch:
> fs/ntfs/ea.c:687 ntfs_new_attr_flags() error: 
> we previously assumed 'ctx' could be null (see line 577)
> 
> Add null pointer check before running  ntfs_attr_put_search_ctx() in 
> error path.
> 
> Fixes: fc053f05ca282 ("ntfs: add reparse and ea operations")
> Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>

Looks good to me. Thanks for the patch.

Reviewed-by: Hyunchul Lee <hyc.lee@gmail.com>

> ---
>  fs/ntfs/ea.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/fs/ntfs/ea.c b/fs/ntfs/ea.c
> index 82ad9b61ec64..b2b0a9a043a9 100644
> --- a/fs/ntfs/ea.c
> +++ b/fs/ntfs/ea.c
> @@ -684,7 +684,8 @@ static int ntfs_new_attr_flags(struct ntfs_inode *ni, __le32 fattr)
>  	a->flags = new_aflags;
>  	mark_mft_record_dirty(ctx->ntfs_ino);
>  err_out:
> -	ntfs_attr_put_search_ctx(ctx);
> +	if (ctx)
> +		ntfs_attr_put_search_ctx(ctx);
>  	unmap_mft_record(ni);
>  	return err;
>  }
> -- 
> 2.53.0
> 

-- 
Thanks,
Hyunchul

  reply	other threads:[~2026-02-26  2:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 22:24 [PATCH] ntfs: Fix null pointer dereference Ethan Tidmore
2026-02-26  2:32 ` Hyunchul Lee [this message]
2026-02-26  9:28 ` 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=aZ-wphvo8fGvJEWY@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