[PATCH] fs: Fix return in jfs_mkdir and orangefs_mkdir

Hongling Zeng posted 1 patch 1 month, 1 week ago
fs/jfs/namei.c      | 2 +-
fs/orangefs/namei.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
[PATCH] fs: Fix return in jfs_mkdir and orangefs_mkdir
Posted by Hongling Zeng 1 month, 1 week ago
Return NULL instead of passing to ERR_PTR while err is zero
Fixes these smatch warnings:
  - fs/jfs/namei.c:311 jfs_mkdir() warn: passing zero to 'ERR_PTR'
  - fs/orangefs/namei.c:369 orangefs_mkdir() warn: passing zero
    to 'ERR_PTR'

Fixes: 88d5baf69082 ("Change inode_operations.mkdir to return struct dentry *")
Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
---
 fs/jfs/namei.c      | 2 +-
 fs/orangefs/namei.c | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
index 60c4a0e0fca5..442d62679262 100644
--- a/fs/jfs/namei.c
+++ b/fs/jfs/namei.c
@@ -309,7 +309,7 @@ static struct dentry *jfs_mkdir(struct mnt_idmap *idmap, struct inode *dip,
       out1:
 
 	jfs_info("jfs_mkdir: rc:%d", rc);
-	return ERR_PTR(rc);
+	return rc ? ERR_PTR(rc) : NULL;
 }
 
 /*
diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
index bec5475de094..75e65e72c2d6 100644
--- a/fs/orangefs/namei.c
+++ b/fs/orangefs/namei.c
@@ -362,7 +362,7 @@ static struct dentry *orangefs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
 	__orangefs_setattr(dir, &iattr);
 out:
 	op_release(new_op);
-	return ERR_PTR(ret);
+	return ret ? ERR_PTR(ret) : NULL;
 }
 
 static int orangefs_rename(struct mnt_idmap *idmap,
-- 
2.25.1
Re: [PATCH] fs: Fix return in jfs_mkdir and orangefs_mkdir
Posted by Christian Brauner 1 month ago
On Fri, 01 May 2026 15:10:58 +0800, Hongling Zeng wrote:
> Return NULL instead of passing to ERR_PTR while err is zero
> Fixes these smatch warnings:
>   - fs/jfs/namei.c:311 jfs_mkdir() warn: passing zero to 'ERR_PTR'
>   - fs/orangefs/namei.c:369 orangefs_mkdir() warn: passing zero
>     to 'ERR_PTR'
> 
> 
> [...]

Applied to the vfs.fixes branch of the vfs/vfs.git tree.
Patches in the vfs.fixes branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a
new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the
patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase,
trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes

[1/1] fs: Fix return in jfs_mkdir and orangefs_mkdir
      https://git.kernel.org/vfs/vfs/c/ff364f9f0cfc
Re: [PATCH] fs: Fix return in jfs_mkdir and orangefs_mkdir
Posted by Jori Koolstra 1 month, 1 week ago
> Op 01-05-2026 09:10 CEST schreef Hongling Zeng <zenghongling@kylinos.cn>:
> 
>  
> Return NULL instead of passing to ERR_PTR while err is zero
> Fixes these smatch warnings:
>   - fs/jfs/namei.c:311 jfs_mkdir() warn: passing zero to 'ERR_PTR'
>   - fs/orangefs/namei.c:369 orangefs_mkdir() warn: passing zero
>     to 'ERR_PTR'
> 
> Fixes: 88d5baf69082 ("Change inode_operations.mkdir to return struct dentry *")
> Signed-off-by: Hongling Zeng <zenghongling@kylinos.cn>
> ---
>  fs/jfs/namei.c      | 2 +-
>  fs/orangefs/namei.c | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/fs/jfs/namei.c b/fs/jfs/namei.c
> index 60c4a0e0fca5..442d62679262 100644
> --- a/fs/jfs/namei.c
> +++ b/fs/jfs/namei.c
> @@ -309,7 +309,7 @@ static struct dentry *jfs_mkdir(struct mnt_idmap *idmap, struct inode *dip,
>        out1:
>  
>  	jfs_info("jfs_mkdir: rc:%d", rc);
> -	return ERR_PTR(rc);
> +	return rc ? ERR_PTR(rc) : NULL;
>  }
>  
>  /*
> diff --git a/fs/orangefs/namei.c b/fs/orangefs/namei.c
> index bec5475de094..75e65e72c2d6 100644
> --- a/fs/orangefs/namei.c
> +++ b/fs/orangefs/namei.c
> @@ -362,7 +362,7 @@ static struct dentry *orangefs_mkdir(struct mnt_idmap *idmap, struct inode *dir,
>  	__orangefs_setattr(dir, &iattr);
>  out:
>  	op_release(new_op);
> -	return ERR_PTR(ret);
> +	return ret ? ERR_PTR(ret) : NULL;
>  }
>  
>  static int orangefs_rename(struct mnt_idmap *idmap,
> -- 
> 2.25.1

Sure. Feel free to add:

Reviewed-by: Jori Koolstra <jkoolstra@xs4all.nl>

However, I will say jfs is kinda low priority, so maybe David will not pick it up.