Re: [PATCH] ntfs: Validate error in ntfs_lookup()

From: CharSyam

Date: Wed May 20 2026 - 11:29:10 EST


Hi, Hongling.

I don't think returning NULL is the right fallback here. This branch is
already the IS_ERR_MREF(mref) path, and -ENOENT has been handled above as
the negative-dentry case. If MREF_ERR(mref) ever decodes to 0 here, it
should probably remain an error, e.g. -EIO, rather than being converted
to a successful lookup return.

Also, I do not see a current producer for MREF_ERR(mref) == 0:
ntfs_lookup_inode_by_name() normalizes zero err to -EIO before
ERR_MREF(err).

The Fixes tag also seems wrong, since the same return is
already present in af0db57d4293^.

Thanks.
DaeMyung.

2026년 5월 20일 (수) 오후 8:16, Hongling Zeng <zenghongling@xxxxxxxxxx>님이 작성:
>
> Check that MREF_ERR returns non-zero before using as error pointer.
> This prevents potential ERR_PTR(0) when error code is zero
>
> Fixes: af0db57d4293 ("ntfs: update inode operations")
> Signed-off-by: Hongling Zeng <zenghongling@xxxxxxxxxx>
> ---
> fs/ntfs/namei.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
> index 10894de519c3..bb075aa97b53 100644
> --- a/fs/ntfs/namei.c
> +++ b/fs/ntfs/namei.c
> @@ -236,7 +236,7 @@ static struct dentry *ntfs_lookup(struct inode *dir_ino, struct dentry *dent,
> }
> ntfs_error(vol->sb, "ntfs_lookup_ino_by_name() failed with error code %i.",
> -MREF_ERR(mref));
> - return ERR_PTR(MREF_ERR(mref));
> + return MREF_ERR(mref) ? ERR_PTR(MREF_ERR(mref)) : NULL;
> handle_name:
> {
> struct mft_record *m;
> --
> 2.25.1
>
>