summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Elder <elder@inktank.com>2013-04-25 23:15:08 -0500
committerSage Weil <sage@inktank.com>2013-05-01 21:19:34 -0700
commit5655c4d940ba8dd32250ab1e4ba3db785943a28e (patch)
treeeca7458b04f89420efe1fdfe576488f9cd6814b9
parentc0fba36880288afbeca872298c970fb4abb76464 (diff)
downloadblackbird-op-linux-5655c4d940ba8dd32250ab1e4ba3db785943a28e.tar.gz
blackbird-op-linux-5655c4d940ba8dd32250ab1e4ba3db785943a28e.zip
rbd: fix image id leak in initial probe
If a format 2 image id is found for an image being mapped, but the subsequent probe of the image fails, rbd_dev_probe() quits without freeing the image id. Fix that. Also drop a redundant hunk of code in rbd_dev_image_id(). Signed-off-by: Alex Elder <elder@inktank.com> Reviewed-by: Josh Durgin <josh.durgin@inktank.com>
-rw-r--r--drivers/block/rbd.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 0ddcbe584a1f..815c174661a8 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -4800,17 +4800,21 @@ static int rbd_dev_probe(struct rbd_device *rbd_dev)
ret = rbd_dev_v1_probe(rbd_dev);
else
ret = rbd_dev_v2_probe(rbd_dev);
- if (ret) {
- dout("probe failed, returning %d\n", ret);
-
- return ret;
- }
+ if (ret)
+ goto out_err;
ret = rbd_dev_probe_finish(rbd_dev);
if (ret)
rbd_header_free(&rbd_dev->header);
return ret;
+out_err:
+ kfree(rbd_dev->spec->image_id);
+ rbd_dev->spec->image_id = NULL;
+
+ dout("probe failed, returning %d\n", ret);
+
+ return ret;
}
static ssize_t rbd_add(struct bus_type *bus,
OpenPOWER on IntegriCloud