Skip to content

Commit

Permalink
rbd: fix image id leak in initial probe
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alex Elder authored and Sage Weil committed May 2, 2013
1 parent c0fba36 commit 5655c4d
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions drivers/block/rbd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4800,16 +4800,20 @@ 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;
}

Expand Down

0 comments on commit 5655c4d

Please sign in to comment.