* [PATCH] ceph: Fix an Oops in error handling
@ 2021-02-02 5:47 ` Dan Carpenter
0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2021-02-02 5:47 UTC (permalink / raw)
To: Jeff Layton; +Cc: Ilya Dryomov, ceph-devel, linux-kernel, kernel-janitors
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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
fs/ceph/addr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 5eec6f66fe52..fb0238a4d34f 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -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);
--
2.29.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH] ceph: Fix an Oops in error handling
@ 2021-02-02 5:47 ` Dan Carpenter
0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2021-02-02 5:47 UTC (permalink / raw)
To: Jeff Layton; +Cc: Ilya Dryomov, ceph-devel, linux-kernel, kernel-janitors
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")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
fs/ceph/addr.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 5eec6f66fe52..fb0238a4d34f 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -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);
--
2.29.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] ceph: Fix an Oops in error handling
2021-02-02 5:47 ` Dan Carpenter
@ 2021-02-02 12:35 ` Ilya Dryomov
-1 siblings, 0 replies; 12+ messages in thread
From: Ilya Dryomov @ 2021-02-02 12:35 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Jeff Layton, Ceph Development, LKML, kernel-janitors
On Tue, Feb 2, 2021 at 6:47 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> fs/ceph/addr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> index 5eec6f66fe52..fb0238a4d34f 100644
> --- a/fs/ceph/addr.c
> +++ b/fs/ceph/addr.c
> @@ -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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] ceph: Fix an Oops in error handling
@ 2021-02-02 12:35 ` Ilya Dryomov
0 siblings, 0 replies; 12+ messages in thread
From: Ilya Dryomov @ 2021-02-02 12:35 UTC (permalink / raw)
To: Dan Carpenter; +Cc: Jeff Layton, Ceph Development, LKML, kernel-janitors
On Tue, Feb 2, 2021 at 6:47 AM Dan Carpenter <dan.carpenter@oracle.com> wrote:
>
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> fs/ceph/addr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> index 5eec6f66fe52..fb0238a4d34f 100644
> --- a/fs/ceph/addr.c
> +++ b/fs/ceph/addr.c
> @@ -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
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] ceph: Fix an Oops in error handling
2021-02-02 5:47 ` Dan Carpenter
@ 2021-02-02 12:37 ` Jeff Layton
-1 siblings, 0 replies; 12+ messages in thread
From: Jeff Layton @ 2021-02-02 12:37 UTC (permalink / raw)
To: Dan Carpenter, David Howells
Cc: Ilya Dryomov, ceph-devel, linux-kernel, kernel-janitors
On Tue, 2021-02-02 at 08:47 +0300, Dan Carpenter wrote:
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> fs/ceph/addr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> index 5eec6f66fe52..fb0238a4d34f 100644
> --- a/fs/ceph/addr.c
> +++ b/fs/ceph/addr.c
> @@ -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);
Good catch.
David, could you take this into your fscache-next branch?
Reviewed-by: Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] ceph: Fix an Oops in error handling
@ 2021-02-02 12:37 ` Jeff Layton
0 siblings, 0 replies; 12+ messages in thread
From: Jeff Layton @ 2021-02-02 12:37 UTC (permalink / raw)
To: Dan Carpenter, David Howells
Cc: Ilya Dryomov, ceph-devel, linux-kernel, kernel-janitors
On Tue, 2021-02-02 at 08:47 +0300, Dan Carpenter wrote:
> 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")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
> fs/ceph/addr.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> index 5eec6f66fe52..fb0238a4d34f 100644
> --- a/fs/ceph/addr.c
> +++ b/fs/ceph/addr.c
> @@ -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);
Good catch.
David, could you take this into your fscache-next branch?
Reviewed-by: Jeff Layton <jlayton@kernel.org>
^ permalink raw reply [flat|nested] 12+ messages in thread
* [PATCH] ceph: fix an oops in error handling in ceph_netfs_issue_op
2021-02-02 5:47 ` Dan Carpenter
@ 2021-02-02 13:10 ` Jeff Layton
-1 siblings, 0 replies; 12+ messages in thread
From: Jeff Layton @ 2021-02-02 13:10 UTC (permalink / raw)
To: dhowells
Cc: dan.carpenter, idryomov, ceph-devel, linux-kernel, kernel-janitors
Dan reported a potential oops in the cleanup if ceph_osdc_new_request
returns an error. Eliminate the unneeded initialization of "req" and
then just set it to NULL in the case where it holds an ERR_PTR.
Also, drop the unneeded NULL check before calling
ceph_osdc_put_request.
Fixes: 1cf7fdf52d5a ("ceph: convert readpage to fscache read helper")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/ceph/addr.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 5eec6f66fe52..0dd64d31eff6 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -234,7 +234,7 @@ static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq)
struct inode *inode = rreq->mapping->host;
struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
- struct ceph_osd_request *req = NULL;
+ struct ceph_osd_request *req;
struct ceph_vino vino = ceph_vino(inode);
struct iov_iter iter;
struct page **pages;
@@ -248,6 +248,7 @@ static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq)
NULL, ci->i_truncate_seq, ci->i_truncate_size, false);
if (IS_ERR(req)) {
err = PTR_ERR(req);
+ req = NULL;
goto out;
}
@@ -273,8 +274,7 @@ static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq)
if (err)
iput(inode);
out:
- if (req)
- ceph_osdc_put_request(req);
+ ceph_osdc_put_request(req);
if (err)
netfs_subreq_terminated(subreq, err);
dout("%s: result %d\n", __func__, err);
--
2.29.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* [PATCH] ceph: fix an oops in error handling in ceph_netfs_issue_op
@ 2021-02-02 13:10 ` Jeff Layton
0 siblings, 0 replies; 12+ messages in thread
From: Jeff Layton @ 2021-02-02 13:10 UTC (permalink / raw)
To: dhowells
Cc: dan.carpenter, idryomov, ceph-devel, linux-kernel, kernel-janitors
Dan reported a potential oops in the cleanup if ceph_osdc_new_request
returns an error. Eliminate the unneeded initialization of "req" and
then just set it to NULL in the case where it holds an ERR_PTR.
Also, drop the unneeded NULL check before calling
ceph_osdc_put_request.
Fixes: 1cf7fdf52d5a ("ceph: convert readpage to fscache read helper")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Suggested-by: Ilya Dryomov <idryomov@gmail.com>
Signed-off-by: Jeff Layton <jlayton@kernel.org>
---
fs/ceph/addr.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
index 5eec6f66fe52..0dd64d31eff6 100644
--- a/fs/ceph/addr.c
+++ b/fs/ceph/addr.c
@@ -234,7 +234,7 @@ static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq)
struct inode *inode = rreq->mapping->host;
struct ceph_inode_info *ci = ceph_inode(inode);
struct ceph_fs_client *fsc = ceph_inode_to_client(inode);
- struct ceph_osd_request *req = NULL;
+ struct ceph_osd_request *req;
struct ceph_vino vino = ceph_vino(inode);
struct iov_iter iter;
struct page **pages;
@@ -248,6 +248,7 @@ static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq)
NULL, ci->i_truncate_seq, ci->i_truncate_size, false);
if (IS_ERR(req)) {
err = PTR_ERR(req);
+ req = NULL;
goto out;
}
@@ -273,8 +274,7 @@ static void ceph_netfs_issue_op(struct netfs_read_subrequest *subreq)
if (err)
iput(inode);
out:
- if (req)
- ceph_osdc_put_request(req);
+ ceph_osdc_put_request(req);
if (err)
netfs_subreq_terminated(subreq, err);
dout("%s: result %d\n", __func__, err);
--
2.29.2
^ permalink raw reply related [flat|nested] 12+ messages in thread
* Re: [PATCH] ceph: Fix an Oops in error handling
2021-02-02 12:37 ` Jeff Layton
@ 2021-02-02 14:19 ` Dan Carpenter
-1 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2021-02-02 14:19 UTC (permalink / raw)
To: Jeff Layton
Cc: David Howells, Ilya Dryomov, ceph-devel, linux-kernel, kernel-janitors
On Tue, Feb 02, 2021 at 07:37:57AM -0500, Jeff Layton wrote:
> On Tue, 2021-02-02 at 08:47 +0300, Dan Carpenter wrote:
> > 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")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > fs/ceph/addr.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> > index 5eec6f66fe52..fb0238a4d34f 100644
> > --- a/fs/ceph/addr.c
> > +++ b/fs/ceph/addr.c
> > @@ -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);
>
> Good catch.
>
> David, could you take this into your fscache-next branch?
>
> Reviewed-by: Jeff Layton <jlayton@kernel.org>
Jeff sent a different fix for this. Let's just apply his instead.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] ceph: Fix an Oops in error handling
@ 2021-02-02 14:19 ` Dan Carpenter
0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2021-02-02 14:19 UTC (permalink / raw)
To: Jeff Layton
Cc: David Howells, Ilya Dryomov, ceph-devel, linux-kernel, kernel-janitors
On Tue, Feb 02, 2021 at 07:37:57AM -0500, Jeff Layton wrote:
> On Tue, 2021-02-02 at 08:47 +0300, Dan Carpenter wrote:
> > 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")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > ---
> > fs/ceph/addr.c | 2 +-
> > 1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c
> > index 5eec6f66fe52..fb0238a4d34f 100644
> > --- a/fs/ceph/addr.c
> > +++ b/fs/ceph/addr.c
> > @@ -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);
>
> Good catch.
>
> David, could you take this into your fscache-next branch?
>
> Reviewed-by: Jeff Layton <jlayton@kernel.org>
Jeff sent a different fix for this. Let's just apply his instead.
regards,
dan carpenter
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] ceph: fix an oops in error handling in ceph_netfs_issue_op
2021-02-02 13:10 ` Jeff Layton
@ 2021-02-02 14:20 ` Dan Carpenter
-1 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2021-02-02 14:20 UTC (permalink / raw)
To: Jeff Layton; +Cc: dhowells, idryomov, ceph-devel, linux-kernel, kernel-janitors
On Tue, Feb 02, 2021 at 08:10:41AM -0500, Jeff Layton wrote:
> Dan reported a potential oops in the cleanup if ceph_osdc_new_request
> returns an error. Eliminate the unneeded initialization of "req" and
> then just set it to NULL in the case where it holds an ERR_PTR.
>
> Also, drop the unneeded NULL check before calling
> ceph_osdc_put_request.
>
> Fixes: 1cf7fdf52d5a ("ceph: convert readpage to fscache read helper")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Suggested-by: Ilya Dryomov <idryomov@gmail.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
Looks good.
Acked-by: Dan Carpenter <dan.carpenter@oracle.com>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: [PATCH] ceph: fix an oops in error handling in ceph_netfs_issue_op
@ 2021-02-02 14:20 ` Dan Carpenter
0 siblings, 0 replies; 12+ messages in thread
From: Dan Carpenter @ 2021-02-02 14:20 UTC (permalink / raw)
To: Jeff Layton; +Cc: dhowells, idryomov, ceph-devel, linux-kernel, kernel-janitors
On Tue, Feb 02, 2021 at 08:10:41AM -0500, Jeff Layton wrote:
> Dan reported a potential oops in the cleanup if ceph_osdc_new_request
> returns an error. Eliminate the unneeded initialization of "req" and
> then just set it to NULL in the case where it holds an ERR_PTR.
>
> Also, drop the unneeded NULL check before calling
> ceph_osdc_put_request.
>
> Fixes: 1cf7fdf52d5a ("ceph: convert readpage to fscache read helper")
> Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
> Suggested-by: Ilya Dryomov <idryomov@gmail.com>
> Signed-off-by: Jeff Layton <jlayton@kernel.org>
Looks good.
Acked-by: Dan Carpenter <dan.carpenter@oracle.com>
regards,
dan carpenter
^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~2021-02-02 14:27 UTC | newest]
Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-02-02 5:47 [PATCH] ceph: Fix an Oops in error handling Dan Carpenter
2021-02-02 5:47 ` Dan Carpenter
2021-02-02 12:35 ` Ilya Dryomov
2021-02-02 12:35 ` Ilya Dryomov
2021-02-02 12:37 ` Jeff Layton
2021-02-02 12:37 ` Jeff Layton
2021-02-02 14:19 ` Dan Carpenter
2021-02-02 14:19 ` Dan Carpenter
2021-02-02 13:10 [PATCH] ceph: fix an oops in error handling in ceph_netfs_issue_op Jeff Layton
2021-02-02 13:10 ` Jeff Layton
2021-02-02 14:20 ` Dan Carpenter
2021-02-02 14:20 ` Dan Carpenter
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.