diff mbox

[2/4] rbd: fix image id leak in initial probe

Message ID 517A94B4.4080804@inktank.com (mailing list archive)
State New, archived
Headers show

Commit Message

Alex Elder April 26, 2013, 2:52 p.m. UTC
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>
---
 drivers/block/rbd.c |   14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

Comments

Josh Durgin April 29, 2013, 3:27 p.m. UTC | #1
Reviewed-by: Josh Durgin <josh.durgin@inktank.com>

On 04/26/2013 07:52 AM, Alex Elder wrote:
> 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>
> ---
>   drivers/block/rbd.c |   14 +++++++++-----
>   1 file changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
> index 0774ae1..e79dfe2 100644
> --- a/drivers/block/rbd.c
> +++ b/drivers/block/rbd.c
> @@ -4794,17 +4794,21 @@ static int rbd_dev_probe(struct rbd_device *rbd_dev)
>   		ret = rbd_dev_v2_probe(rbd_dev);
>   	else
>   		ret = rbd_dev_v1_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,
>

--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c
index 0774ae1..e79dfe2 100644
--- a/drivers/block/rbd.c
+++ b/drivers/block/rbd.c
@@ -4794,17 +4794,21 @@  static int rbd_dev_probe(struct rbd_device *rbd_dev)
 		ret = rbd_dev_v2_probe(rbd_dev);
 	else
 		ret = rbd_dev_v1_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,