aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/block/rbd.c
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2012-11-30 10:59:47 -0500
committerAlex Elder <elder@inktank.com>2013-01-17 17:34:58 -0500
commit1821665749a3d7e26ad470c63fc2c46990dc6041 (patch)
tree5bcb560bcb31abf5af0dc723ccc4485f6062e86f /drivers/block/rbd.c
parent2e53c6c379b65372df21f4d6019f6eb63af81384 (diff)
rbd: don't leak rbd_req for rbd_req_sync_notify_ack()
When rbd_req_sync_notify_ack() calls rbd_do_request() it supplies rbd_simple_req_cb() as its callback function. Because the callback is supplied, an rbd_req structure gets allocated and populated so it can be used by the callback. However rbd_simple_req_cb() is not freeing (or even using) the rbd_req structure, so it's getting leaked. Since rbd_simple_req_cb() has no need for the rbd_req structure, just avoid allocating one for this case. Of the three calls to rbd_do_request(), only the one from rbd_do_op() needs the rbd_req structure, and that call can be distinguished from the other two because it supplies a non-null rbd_collection pointer. So fix this leak by only allocating the rbd_req structure if a non-null "coll" value is provided to rbd_do_request(). Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
Diffstat (limited to 'drivers/block/rbd.c')
-rw-r--r--drivers/block/rbd.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 28b62367ff93..619d680960b1 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -1135,7 +1135,7 @@ static int rbd_do_request(struct request *rq,
1135 bio_get(osd_req->r_bio); 1135 bio_get(osd_req->r_bio);
1136 } 1136 }
1137 1137
1138 if (rbd_cb) { 1138 if (coll) {
1139 ret = -ENOMEM; 1139 ret = -ENOMEM;
1140 rbd_req = kmalloc(sizeof(*rbd_req), GFP_NOIO); 1140 rbd_req = kmalloc(sizeof(*rbd_req), GFP_NOIO);
1141 if (!rbd_req) 1141 if (!rbd_req)
@@ -1146,7 +1146,7 @@ static int rbd_do_request(struct request *rq,
1146 rbd_req->pages = pages; 1146 rbd_req->pages = pages;
1147 rbd_req->len = len; 1147 rbd_req->len = len;
1148 rbd_req->coll = coll; 1148 rbd_req->coll = coll;
1149 rbd_req->coll_index = coll ? coll_index : 0; 1149 rbd_req->coll_index = coll_index;
1150 } 1150 }
1151 1151
1152 osd_req->r_callback = rbd_cb; 1152 osd_req->r_callback = rbd_cb;