summaryrefslogtreecommitdiff
path: root/net/ceph/osd_client.c
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-02-15 22:10:17 -0600
committerSage Weil <sage@inktank.com>2013-05-01 21:14:22 -0700
commit3ff5f385b1449a07372d51fb89ca94dbfb6a3be2 (patch)
tree0d902d547dc2f9efe843b94d6a88478563e5e240 /net/ceph/osd_client.c
parentc1be5a5b1b355d40e6cf79cc979eb66dafa24ad1 (diff)
libceph: fix a osd request memory leak
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> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'net/ceph/osd_client.c')
-rw-r--r--net/ceph/osd_client.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/net/ceph/osd_client.c b/net/ceph/osd_client.c
index d730dd4d8eb2..cf4e15bfe0db 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;
}
/*
@@ -470,8 +470,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