[PATCH 1/2] ntfs: Replace ERR_PTR(0) with NULL

Ethan Tidmore posted 2 patches 1 month, 1 week ago
[PATCH 1/2] ntfs: Replace ERR_PTR(0) with NULL
Posted by Ethan Tidmore 1 month, 1 week ago
The variable err is confirmed to be 0 and then never reassigned in the
success path. The function then returns with ERR_PTR(err) which just
equals NULL and can be misleading.

Detected by Smatch:
fs/ntfs/namei.c:1091 ntfs_mkdir() warn:
passing zero to 'ERR_PTR'

Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 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 a21eeaec57b4..cecfaabfbfe7 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -1088,7 +1088,7 @@ static struct dentry *ntfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
 	}
 
 	d_instantiate_new(dentry, VFS_I(ni));
-	return ERR_PTR(err);
+	return NULL;
 }
 
 static int ntfs_rmdir(struct inode *dir, struct dentry *dentry)
-- 
2.53.0
Re: [PATCH 1/2] ntfs: Replace ERR_PTR(0) with NULL
Posted by Hyunchul Lee 1 month, 1 week ago
On Wed, Feb 25, 2026 at 10:03:54PM -0600, Ethan Tidmore wrote:
> The variable err is confirmed to be 0 and then never reassigned in the
> success path. The function then returns with ERR_PTR(err) which just
> equals NULL and can be misleading.
> 
> Detected by Smatch:
> fs/ntfs/namei.c:1091 ntfs_mkdir() warn:
> passing zero to 'ERR_PTR'
> 
> 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/namei.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
> index a21eeaec57b4..cecfaabfbfe7 100644
> --- a/fs/ntfs/namei.c
> +++ b/fs/ntfs/namei.c
> @@ -1088,7 +1088,7 @@ static struct dentry *ntfs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
>  	}
>  
>  	d_instantiate_new(dentry, VFS_I(ni));
> -	return ERR_PTR(err);
> +	return NULL;
>  }
>  
>  static int ntfs_rmdir(struct inode *dir, struct dentry *dentry)
> -- 
> 2.53.0
> 

-- 
Thanks,
Hyunchul