All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libceph: fix a osd request memory leak
@ 2013-02-25 22:36 Alex Elder
  2013-02-26 18:12 ` Josh Durgin
  0 siblings, 1 reply; 2+ messages in thread
From: Alex Elder @ 2013-02-25 22:36 UTC (permalink / raw)
  To: ceph-devel@vger.kernel.org

If an invalid layout is provided to ceph_osdc_new_request(), its
call to calc_layout() might return an error.  At that point in the
function we've already allocated an osd request structure, so we
need to free it (drop a reference) in the event such an error
occurs.

The only other value calc_layout() will return is 0, so make that
explicit in the successful case.

This resolves:
    http://tracker.ceph.com/issues/4240

Signed-off-by: Alex Elder <elder@inktank.com>
---
 net/ceph/osd_client.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index 39629b6..5daced2 100644
--- a/net/ceph/osd_client.c
+++ b/net/ceph/osd_client.c
@@ -109,7 +109,7 @@ static int calc_layout(struct ceph_vino vino,
 	snprintf(req->r_oid, sizeof(req->r_oid), "%llx.%08llx", vino.ino, bno);
 	req->r_oid_len = strlen(req->r_oid);

-	return r;
+	return 0;
 }

 /*
@@ -437,8 +437,10 @@ struct ceph_osd_request
*ceph_osdc_new_request(struct ceph_osd_client *osdc,

 	/* calculate max write size */
 	r = calc_layout(vino, layout, off, plen, req, ops);
-	if (r < 0)
+	if (r < 0) {
+		ceph_osdc_put_request(req);
 		return ERR_PTR(r);
+	}
 	req->r_file_layout = *layout;  /* keep a copy */

 	/* in case it differs from natural (file) alignment that
-- 
1.7.9.5


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

* Re: [PATCH] libceph: fix a osd request memory leak
  2013-02-25 22:36 [PATCH] libceph: fix a osd request memory leak Alex Elder
@ 2013-02-26 18:12 ` Josh Durgin
  0 siblings, 0 replies; 2+ messages in thread
From: Josh Durgin @ 2013-02-26 18:12 UTC (permalink / raw)
  To: Alex Elder; +Cc: ceph-devel@vger.kernel.org

Reviewed-by: Josh Durgin <josh.durgin@inktank.com>

On 02/25/2013 02:36 PM, Alex Elder wrote:
> If an invalid layout is provided to ceph_osdc_new_request(), its
> call to calc_layout() might return an error.  At that point in the
> function we've already allocated an osd request structure, so we
> need to free it (drop a reference) in the event such an error
> occurs.
>
> The only other value calc_layout() will return is 0, so make that
> explicit in the successful case.
>
> This resolves:
>      http://tracker.ceph.com/issues/4240
>
> Signed-off-by: Alex Elder <elder@inktank.com>
> ---
>   net/ceph/osd_client.c |    6 ++++--
>   1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
> index 39629b6..5daced2 100644
> --- a/net/ceph/osd_client.c
> +++ b/net/ceph/osd_client.c
> @@ -109,7 +109,7 @@ static int calc_layout(struct ceph_vino vino,
>   	snprintf(req->r_oid, sizeof(req->r_oid), "%llx.%08llx", vino.ino, bno);
>   	req->r_oid_len = strlen(req->r_oid);
>
> -	return r;
> +	return 0;
>   }
>
>   /*
> @@ -437,8 +437,10 @@ struct ceph_osd_request
> *ceph_osdc_new_request(struct ceph_osd_client *osdc,
>
>   	/* calculate max write size */
>   	r = calc_layout(vino, layout, off, plen, req, ops);
> -	if (r < 0)
> +	if (r < 0) {
> +		ceph_osdc_put_request(req);
>   		return ERR_PTR(r);
> +	}
>   	req->r_file_layout = *layout;  /* keep a copy */
>
>   	/* in case it differs from natural (file) alignment that
>


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

end of thread, other threads:[~2013-02-26 18:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-02-25 22:36 [PATCH] libceph: fix a osd request memory leak Alex Elder
2013-02-26 18:12 ` Josh Durgin

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.