Skip to contentSkip to conversation

exfat: fix passing zero to ERR_PTR() in exfat_mkdir()

PATCH Applied Yang Wen 2 participants 2 messages Mar 22 – Mar 23

Subsystems (2)
lore
Share & tools
lore

Yang Wen

author
#0 lore raw

PATCH 1/1 exfat: fix passing zero to ERR_PTR() in exfat_mkdir()

Detected by Smatch.

namei.c:890 exfat_mkdir() warn:
passing zero to 'ERR_PTR'

---
 fs/exfat/namei.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)
fs/exfat/namei.c +4 -3
index 670116ae9ec8..2bfdece79b17 100644
@@ -873,9 +873,10 @@ static struct dentry *exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir,
 
 	i_pos = exfat_make_i_pos(&info);
 	inode = exfat_build_inode(sb, &info, i_pos);
-	err = PTR_ERR_OR_ZERO(inode);
-	if (err)
+	if (IS_ERR(inode)) {
+		err = PTR_ERR(inode);
 		goto unlock;
+	}
 
 	inode_inc_iversion(inode);
 	EXFAT_I(inode)->i_crtime = simple_inode_init_ts(inode);
@@ -886,7 +887,7 @@ static struct dentry *exfat_mkdir(struct mnt_idmap *idmap, struct inode *dir,
 
 unlock:
 	mutex_unlock(&EXFAT_SB(sb)->s_lock);
-	return ERR_PTR(err);
+	return err ? ERR_PTR(err) : NULL;
 }
 
 static int exfat_check_dir_empty(struct super_block *sb,
Signature · 1 line
2.43.0