qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Michael Roth <mdroth@linux.vnet.ibm.com>
Cc: Josh Durgin <josh.durgin@inktank.com>,
	qemu-devel@nongnu.org, Stefan Hajnoczi <stefanha@redhat.com>,
	qemu-stable@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] rbd: avoid qemu_rbd_snap_list() memory leak when no snapshots
Date: Wed, 25 Sep 2013 10:06:11 +0200	[thread overview]
Message-ID: <20130925080611.GA2898@dhcp-200-207.str.redhat.com> (raw)
In-Reply-To: <20130925002823.25429.86191@loki>

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.

Kevin

  reply	other threads:[~2013-09-25  8:06 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 [this message]
2013-09-25 13:58     ` Stefan Hajnoczi

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=20130925080611.GA2898@dhcp-200-207.str.redhat.com \
    --to=kwolf@redhat.com \
    --cc=josh.durgin@inktank.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-stable@nongnu.org \
    --cc=stefanha@redhat.com \
    /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).