From: Stefan Hajnoczi <stefanha@redhat.com>
To: Kevin Wolf <kwolf@redhat.com>
Cc: Josh Durgin <josh.durgin@inktank.com>,
qemu-stable@nongnu.org, Michael Roth <mdroth@linux.vnet.ibm.com>,
qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] rbd: avoid qemu_rbd_snap_list() memory leak when no snapshots
Date: Wed, 25 Sep 2013 15:58:02 +0200 [thread overview]
Message-ID: <20130925135802.GA13589@stefanha-thinkpad.redhat.com> (raw)
In-Reply-To: <20130925080611.GA2898@dhcp-200-207.str.redhat.com>
On Wed, Sep 25, 2013 at 10:06:11AM +0200, Kevin Wolf wrote:
> Am 25.09.2013 um 02:28 hat Michael Roth geschrieben:
> > Quoting Stefan Hajnoczi (2013-08-14 07:13:52)
> > > When there are no snapshots qemu_rbd_snap_list() returns 0 and the
> > > snapshot table pointer is NULL. Don't forget to free the snaps buffer
> > > we allocated for librbd rbd_snap_list().
> > >
> > > Cc: qemu-stable@nongnu.org
> > > Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
> >
> > Ping for 1.6.1
>
> Applied it to the block branch for now, but...
>
> > > ---
> > > block/rbd.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/block/rbd.c b/block/rbd.c
> > > index cb71751..4e26fea 100644
> > > --- a/block/rbd.c
> > > +++ b/block/rbd.c
> > > @@ -934,7 +934,7 @@ static int qemu_rbd_snap_list(BlockDriverState *bs,
> > > do {
> > > snaps = g_malloc(sizeof(*snaps) * max_snaps);
> > > snap_count = rbd_snap_list(s->image, snaps, &max_snaps);
> > > - if (snap_count < 0) {
> > > + if (snap_count <= 0) {
> > > g_free(snaps);
> > > }
> > > } while (snap_count == -ERANGE);
>
> ...I think this isn't a complete fix. In the successful case we still
> leak snaps. The g_free() should probably be moved to after the done:
> label in a v2 of the patch.
You are right. I'm sending a v2. rbd_snap_list_end() does not free
snaps itself, only the strings that snaps[i].name points to. Therefore
we need to free snaps.
prev parent reply other threads:[~2013-09-25 13:58 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-08-14 12:13 [Qemu-devel] [PATCH] rbd: avoid qemu_rbd_snap_list() memory leak when no snapshots Stefan Hajnoczi
2013-09-25 0:28 ` Michael Roth
2013-09-25 8:06 ` Kevin Wolf
2013-09-25 13:58 ` Stefan Hajnoczi [this message]
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=20130925135802.GA13589@stefanha-thinkpad.redhat.com \
--to=stefanha@redhat.com \
--cc=josh.durgin@inktank.com \
--cc=kwolf@redhat.com \
--cc=mdroth@linux.vnet.ibm.com \
--cc=qemu-devel@nongnu.org \
--cc=qemu-stable@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).