public inbox for linux-fsdevel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] ntfs: Fix two minor issues in namei.c
@ 2026-02-26  4:03 Ethan Tidmore
  2026-02-26  4:03 ` [PATCH 1/2] ntfs: Replace ERR_PTR(0) with NULL Ethan Tidmore
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Ethan Tidmore @ 2026-02-26  4:03 UTC (permalink / raw)
  To: linkinjeon, hyc.lee; +Cc: linux-fsdevel, linux-kernel, Ethan Tidmore

Here are two non-bug issues but should be fixed.

Ethan Tidmore (2):
  ntfs: Replace ERR_PTR(0) with NULL
  ntfs: Remove impossible condition

 fs/ntfs/namei.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] ntfs: Replace ERR_PTR(0) with NULL
  2026-02-26  4:03 [PATCH 0/2] ntfs: Fix two minor issues in namei.c Ethan Tidmore
@ 2026-02-26  4:03 ` Ethan Tidmore
  2026-02-26  5:39   ` Hyunchul Lee
  2026-02-26  4:03 ` [PATCH 2/2] ntfs: Remove impossible condition Ethan Tidmore
  2026-02-26  9:29 ` [PATCH 0/2] ntfs: Fix two minor issues in namei.c Namjae Jeon
  2 siblings, 1 reply; 6+ messages in thread
From: Ethan Tidmore @ 2026-02-26  4:03 UTC (permalink / raw)
  To: linkinjeon, hyc.lee; +Cc: linux-fsdevel, linux-kernel, Ethan Tidmore

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/2] ntfs: Remove impossible condition
  2026-02-26  4:03 [PATCH 0/2] ntfs: Fix two minor issues in namei.c Ethan Tidmore
  2026-02-26  4:03 ` [PATCH 1/2] ntfs: Replace ERR_PTR(0) with NULL Ethan Tidmore
@ 2026-02-26  4:03 ` Ethan Tidmore
  2026-02-26  5:40   ` Hyunchul Lee
  2026-02-26  9:29 ` [PATCH 0/2] ntfs: Fix two minor issues in namei.c Namjae Jeon
  2 siblings, 1 reply; 6+ messages in thread
From: Ethan Tidmore @ 2026-02-26  4:03 UTC (permalink / raw)
  To: linkinjeon, hyc.lee; +Cc: linux-fsdevel, linux-kernel, Ethan Tidmore

The variable name_len is checked to see if it's larger than the macro
NTFS_MAX_NAME_LEN however this condition is impossible because name_len
is of type u8 and NTFS_MAX_NAME_LEN is hardcoded to be 255.

Detected by Smatch:
fs/ntfs/namei.c:1175 __ntfs_link() warn:
impossible condition '(name_len > 255) => (0-255 > 255)'

Signed-off-by: Ethan Tidmore <ethantidmore06@gmail.com>
---
 fs/ntfs/namei.c | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
index cecfaabfbfe7..2952b377dda2 100644
--- a/fs/ntfs/namei.c
+++ b/fs/ntfs/namei.c
@@ -1172,10 +1172,7 @@ static int __ntfs_link(struct ntfs_inode *ni, struct ntfs_inode *dir_ni,
 
 	/* Create FILE_NAME attribute. */
 	fn_len = sizeof(struct file_name_attr) + name_len * sizeof(__le16);
-	if (name_len > NTFS_MAX_NAME_LEN) {
-		err = -EIO;
-		goto err_out;
-	}
+
 	fn = kzalloc(fn_len, GFP_NOFS);
 	if (!fn) {
 		err = -ENOMEM;
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/2] ntfs: Replace ERR_PTR(0) with NULL
  2026-02-26  4:03 ` [PATCH 1/2] ntfs: Replace ERR_PTR(0) with NULL Ethan Tidmore
@ 2026-02-26  5:39   ` Hyunchul Lee
  0 siblings, 0 replies; 6+ messages in thread
From: Hyunchul Lee @ 2026-02-26  5:39 UTC (permalink / raw)
  To: Ethan Tidmore; +Cc: linkinjeon, linux-fsdevel, linux-kernel

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 2/2] ntfs: Remove impossible condition
  2026-02-26  4:03 ` [PATCH 2/2] ntfs: Remove impossible condition Ethan Tidmore
@ 2026-02-26  5:40   ` Hyunchul Lee
  0 siblings, 0 replies; 6+ messages in thread
From: Hyunchul Lee @ 2026-02-26  5:40 UTC (permalink / raw)
  To: Ethan Tidmore; +Cc: linkinjeon, linux-fsdevel, linux-kernel

On Wed, Feb 25, 2026 at 10:03:55PM -0600, Ethan Tidmore wrote:
> The variable name_len is checked to see if it's larger than the macro
> NTFS_MAX_NAME_LEN however this condition is impossible because name_len
> is of type u8 and NTFS_MAX_NAME_LEN is hardcoded to be 255.
> 
> Detected by Smatch:
> fs/ntfs/namei.c:1175 __ntfs_link() warn:
> impossible condition '(name_len > 255) => (0-255 > 255)'
> 
> 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 | 5 +----
>  1 file changed, 1 insertion(+), 4 deletions(-)
> 
> diff --git a/fs/ntfs/namei.c b/fs/ntfs/namei.c
> index cecfaabfbfe7..2952b377dda2 100644
> --- a/fs/ntfs/namei.c
> +++ b/fs/ntfs/namei.c
> @@ -1172,10 +1172,7 @@ static int __ntfs_link(struct ntfs_inode *ni, struct ntfs_inode *dir_ni,
>  
>  	/* Create FILE_NAME attribute. */
>  	fn_len = sizeof(struct file_name_attr) + name_len * sizeof(__le16);
> -	if (name_len > NTFS_MAX_NAME_LEN) {
> -		err = -EIO;
> -		goto err_out;
> -	}
> +
>  	fn = kzalloc(fn_len, GFP_NOFS);
>  	if (!fn) {
>  		err = -ENOMEM;
> -- 
> 2.53.0
> 

-- 
Thanks,
Hyunchul

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] ntfs: Fix two minor issues in namei.c
  2026-02-26  4:03 [PATCH 0/2] ntfs: Fix two minor issues in namei.c Ethan Tidmore
  2026-02-26  4:03 ` [PATCH 1/2] ntfs: Replace ERR_PTR(0) with NULL Ethan Tidmore
  2026-02-26  4:03 ` [PATCH 2/2] ntfs: Remove impossible condition Ethan Tidmore
@ 2026-02-26  9:29 ` Namjae Jeon
  2 siblings, 0 replies; 6+ messages in thread
From: Namjae Jeon @ 2026-02-26  9:29 UTC (permalink / raw)
  To: Ethan Tidmore; +Cc: hyc.lee, linux-fsdevel, linux-kernel

On Thu, Feb 26, 2026 at 1:04 PM Ethan Tidmore <ethantidmore06@gmail.com> wrote:
>
> Here are two non-bug issues but should be fixed.
>
> Ethan Tidmore (2):
>   ntfs: Replace ERR_PTR(0) with NULL
>   ntfs: Remove impossible condition
Applied it to #ntfs-next.
Thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-02-26  9:29 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-26  4:03 [PATCH 0/2] ntfs: Fix two minor issues in namei.c Ethan Tidmore
2026-02-26  4:03 ` [PATCH 1/2] ntfs: Replace ERR_PTR(0) with NULL Ethan Tidmore
2026-02-26  5:39   ` Hyunchul Lee
2026-02-26  4:03 ` [PATCH 2/2] ntfs: Remove impossible condition Ethan Tidmore
2026-02-26  5:40   ` Hyunchul Lee
2026-02-26  9:29 ` [PATCH 0/2] ntfs: Fix two minor issues in namei.c Namjae Jeon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox