From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: Bob Liu <bob.liu@oracle.com>
Cc: xen-devel@lists.xenproject.org, linux-kernel@vger.kernel.org,
roger.pau@citrix.com
Subject: Re: [PATCH] xen-blkback: fix two memleaks
Date: Fri, 11 Dec 2015 12:24:01 -0500 [thread overview]
Message-ID: <20151211172401.GA9765@char.us.oracle.com> (raw)
In-Reply-To: <1449710208-7806-1-git-send-email-bob.liu@oracle.com>
> 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
>
next prev parent reply other threads:[~2015-12-11 17:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-10 1:16 [PATCH] xen-blkback: fix two memleaks Bob Liu
2015-12-11 17:24 ` Konrad Rzeszutek Wilk [this message]
2015-12-11 21:00 ` Konrad Rzeszutek Wilk
-- strict thread matches above, loose matches on Subject: below --
2015-12-10 1:16 Bob Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20151211172401.GA9765@char.us.oracle.com \
--to=konrad.wilk@oracle.com \
--cc=bob.liu@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=roger.pau@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.