Skip to contentSkip to conversation

ceph: Fix an Oops in error handling

PATCH In review Dan Carpenter 3 participants 4 messages Feb 2, 2021

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

PATCH 1/1 ceph: Fix an Oops in error handling

The "req" pointer is an error pointer and not NULL so this check needs to be fixed.

Fixes 1cf7fdf52d5a ("ceph: convert readpage to fscache read helper")
---
 fs/ceph/addr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/addr.c +1 -1
index 5eec6f66fe52..fb0238a4d34f 100644
@@ -273,7 +273,7 @@ static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq)
 	if (err)
 		iput(inode);
 out:
-	if (req)
+	if (!IS_ERR_OR_NULL(req))
 		ceph_osdc_put_request(req);
 	if (err)
 		netfs_subreq_terminated(subreq, err);
Signature · 1 line
2.29.2
maintainer
#1 lore raw
Quoted 15 lines · Dan Carpenter

The "req" pointer is an error pointer and not NULL so this check needs to be fixed.

Fixes 1cf7fdf52d5a ("ceph: convert readpage to fscache read helper")
---
 fs/ceph/addr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/addr.c +0 -0
index 5eec6f66fe52..fb0238a4d34f 100644

fs/ceph/addr.c static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq) · line 279

Quoted 8 lines
fs/ceph/addr.c +1 -1
@@ -273,7 +273,7 @@ static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq)
        if (err)
                iput(inode);
 out:
-       if (req)
+       if (!IS_ERR_OR_NULL(req))
                ceph_osdc_put_request(req);
        if (err)
                netfs_subreq_terminated(subreq, err);

Hi Dan,

I think a better fix would be to set req to NULL in the offending IS_ERR branch since ceph_osdc_new_request() never returns NULL or use two separate goto labels.

While at it, the initialization of req and the check on req before calling ceph_osdc_put_request() are redundant.

Thanks,

Ilya

Reviewed-by on v1 1/1
#2 lore raw
In reply to Dan Carpenter
Quoted 19 lines · Dan Carpenter

The "req" pointer is an error pointer and not NULL so this check needs to be fixed.

Fixes 1cf7fdf52d5a ("ceph: convert readpage to fscache read helper")

---
 fs/ceph/addr.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/addr.c +0 -0
index 5eec6f66fe52..fb0238a4d34f 100644
@@ -273,7 +273,7 @@ static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq)
  	if (err)
  		iput(inode);

 out:

fs/ceph/addr.c +1 -1
-	if (req)
+	if (!IS_ERR_OR_NULL(req))
Quoted 3 lines

  ceph_osdc_put_request(req); if (err) netfs_subreq_terminated(subreq, err);

Good catch.

David, could you take this into your fscache-next branch?

#3 lore raw
Quoted 26 lines · Jeff Layton
Quoted 19 lines · Dan Carpenter

The "req" pointer is an error pointer and not NULL so this check needs to be fixed.

Fixes 1cf7fdf52d5a ("ceph: convert readpage to fscache read helper")

---
 fs/ceph/addr.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
fs/ceph/addr.c +0 -0
index 5eec6f66fe52..fb0238a4d34f 100644
@@ -273,7 +273,7 @@ static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq)
  	if (err)
  		iput(inode);

 out:

fs/ceph/addr.c +1 -1
-	if (req)
+	if (!IS_ERR_OR_NULL(req))
Quoted 3 lines

  ceph_osdc_put_request(req); if (err) netfs_subreq_terminated(subreq, err);

Good catch.

Quoted 3 lines

David, could you take this into your fscache-next branch?

Jeff sent a different fix for this. Let's just apply his instead.

regards,
dan carpenter