|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [PATCH] xen-blkback: fix two memleaks
> diff --git a/drivers/block/xen-blkback/xenbus.c
> b/drivers/block/xen-blkback/xenbus.c
> index 44396b8..dabdb18 100644
> --- a/drivers/block/xen-blkback/xenbus.c
> +++ b/drivers/block/xen-blkback/xenbus.c
> @@ -246,6 +246,9 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
> struct pending_req *req, *n;
> unsigned int j, r;
>
> + if (!blkif->rings)
> + goto out;
> +
I dropped this and instead added: blkif->nr_rings = 0.
Which will mean we can still run through this function many
times but that should not be a problem.
> for (r = 0; r < blkif->nr_rings; r++) {
> struct xen_blkif_ring *ring = &blkif->rings[r];
> unsigned int i = 0;
> @@ -299,7 +302,14 @@ static int xen_blkif_disconnect(struct xen_blkif *blkif)
> WARN_ON(i != (XEN_BLKIF_REQS_PER_PAGE * blkif->nr_ring_pages));
> }
> blkif->nr_ring_pages = 0;
> + /*
> + * blkif->rings was allocated in connect_ring, so we should free it in
> + * disconnect.
s/disconnect/here/
> + */
> + kfree(blkif->rings);
> + blkif->rings = NULL;
And perhaps also:
blkif->nr_rings = 0?
>
> +out:
> return 0;
> }
>
> @@ -310,7 +320,6 @@ static void xen_blkif_free(struct xen_blkif *blkif)
> xen_vbd_free(&blkif->vbd);
>
> /* Make sure everything is drained before shutting down */
> - kfree(blkif->rings);
> kmem_cache_free(xen_blkif_cachep, blkif);
> }
>
> @@ -505,6 +514,8 @@ static int xen_blkbk_remove(struct xenbus_device *dev)
> xen_blkif_put(be->blkif);
> }
>
> + /* Put the reference got in xen_blkif_alloc(). */
s/got/we set/
Updated this and testing it as such.
> + xen_blkif_put(be->blkif);
> kfree(be->mode);
> kfree(be);
> return 0;
> --
> 1.7.10.4
>
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |