Skip to contentSkip to conversation

ceph: fix a NULL vs IS_ERR() check

PATCH In review Dan Carpenter 3 participants 3 messages Oct 14, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ceph: fix a NULL vs IS_ERR() check

The ceph_lookup_inode() function returns error pointers. It never returns NULL.

Fixes aa87052dd965 ("ceph: fix incorrectly showing the .snap size for stat")
---
 fs/ceph/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/inode.c +1 -1
index 4af5e55abc15..bad9eeb6a1a5 100644
@@ -2492,7 +2492,7 @@ int ceph_getattr(struct user_namespace *mnt_userns, const struct path *path,
 			struct inode *parent;
 
 			parent = ceph_lookup_inode(sb, ceph_ino(inode));
-			if (!parent)
+			if (IS_ERR(parent))
 				return PTR_ERR(parent);
 
 			pci = ceph_inode(parent);
Signature · 1 line
2.35.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 14 lines · Dan Carpenter

The ceph_lookup_inode() function returns error pointers. It never returns NULL.

Fixes aa87052dd965 ("ceph: fix incorrectly showing the .snap size for stat")
---
 fs/ceph/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/inode.c +0 -0
index 4af5e55abc15..bad9eeb6a1a5 100644

fs/ceph/inode.c int ceph_getattr(struct user_namespace *mnt_userns, const struct path *path, · line 2498

Quoted 8 lines
fs/ceph/inode.c +1 -1
@@ -2492,7 +2492,7 @@ int ceph_getattr(struct user_namespace *mnt_userns, const struct path *path,
 			struct inode *parent;
 
 			parent = ceph_lookup_inode(sb, ceph_ino(inode));
-			if (!parent)
+			if (IS_ERR(parent))
 				return PTR_ERR(parent);
 
 			pci = ceph_inode(parent);
#2 lore raw
In reply to Dan Carpenter
Quoted 14 lines · Dan Carpenter

The ceph_lookup_inode() function returns error pointers. It never returns NULL.

Fixes aa87052dd965 ("ceph: fix incorrectly showing the .snap size for stat")
---
  fs/ceph/inode.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/inode.c +0 -0
index 4af5e55abc15..bad9eeb6a1a5 100644

fs/ceph/inode.c int ceph_getattr(struct user_namespace *mnt_userns, const struct path *path, · line 2498

Quoted 8 lines
fs/ceph/inode.c +1 -1
@@ -2492,7 +2492,7 @@ int ceph_getattr(struct user_namespace *mnt_userns, const struct path *path,
  			struct inode *parent;
 
  			parent = ceph_lookup_inode(sb, ceph_ino(inode));
-			if (!parent)
+			if (IS_ERR(parent))
  				return PTR_ERR(parent);
 
  			pci = ceph_inode(parent);

Good catch!

Will merge it to the testing branch soon.

Thanks Dan.

- Xiubo