mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] ovl: Fix PTR_ERR zero argument warning
@ 2025-05-19  4:11 Charles Han
  2025-05-19  6:43 ` Amir Goldstein
  0 siblings, 1 reply; 3+ messages in thread
From: Charles Han @ 2025-05-19  4:11 UTC (permalink / raw)
  To: miklos, amir73il; +Cc: linux-kernel, Charles Han

In the ovl_check_origin()  and ovl_index_upper()function, the
PTR_ERR function was potentially passed a null pointer.
To fix this issue, separated the null pointer check and the error
pointer check, ensuring that PTR_ERR is only called with a valid
error pointer.

Fix below smatch warning.
smatch warnings:
fs/overlayfs/namei.c:479 ovl_check_origin() warn: passing zero to 'PTR_ERR'
fs/overlayfs/namei.c:581 ovl_index_upper() warn: passing zero to 'ERR_CAST'

Fixes: ad1d615cec1c ("ovl: use directory index entries for consistency verification")
Fixes: e8f9e5b780b0 ("ovl: verify directory index entries on mount")
Signed-off-by: Charles Han <hanchunchao@inspur.com>
---
 fs/overlayfs/namei.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c
index 0b8b28392eb7..bc917b56e2b1 100644
--- a/fs/overlayfs/namei.c
+++ b/fs/overlayfs/namei.c
@@ -475,7 +475,9 @@ static int ovl_check_origin(struct ovl_fs *ofs, struct dentry *upperdentry,
 	struct ovl_fh *fh = ovl_get_fh(ofs, upperdentry, OVL_XATTR_ORIGIN);
 	int err;
 
-	if (IS_ERR_OR_NULL(fh))
+	if (!fh)
+		return -ENODATA;
+	else if (IS_ERR(fh))
 		return PTR_ERR(fh);
 
 	err = ovl_check_origin_fh(ofs, fh, false, upperdentry, stackp);
@@ -577,7 +579,9 @@ struct dentry *ovl_index_upper(struct ovl_fs *ofs, struct dentry *index,
 		return dget(index);
 
 	fh = ovl_get_fh(ofs, index, OVL_XATTR_UPPER);
-	if (IS_ERR_OR_NULL(fh))
+	if (!fh)
+		return ERR_PTR(-ENODATA);
+	else if (IS_ERR(fh))
 		return ERR_CAST(fh);
 
 	upper = ovl_decode_real_fh(ofs, fh, ovl_upper_mnt(ofs), connected);
-- 
2.43.0


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

end of thread, other threads:[~2025-05-23  7:34 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-05-19  4:11 [PATCH] ovl: Fix PTR_ERR zero argument warning Charles Han
2025-05-19  6:43 ` Amir Goldstein
2025-05-23  7:34   ` Dan Carpenter

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

all inboxes | Powered by JetHome®