From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOcy7-0002uW-2s for qemu-devel@nongnu.org; Tue, 24 Sep 2013 20:28:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VOcxx-0001Kl-Na for qemu-devel@nongnu.org; Tue, 24 Sep 2013 20:28:39 -0400 Received: from e33.co.us.ibm.com ([32.97.110.151]:40098) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VOcxx-0001KU-Fs for qemu-devel@nongnu.org; Tue, 24 Sep 2013 20:28:29 -0400 Received: from /spool/local by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 24 Sep 2013 18:28:28 -0600 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Michael Roth In-Reply-To: <1376482432-24929-1-git-send-email-stefanha@redhat.com> References: <1376482432-24929-1-git-send-email-stefanha@redhat.com> Message-ID: <20130925002823.25429.86191@loki> Date: Tue, 24 Sep 2013 19:28:23 -0500 Subject: Re: [Qemu-devel] [PATCH] rbd: avoid qemu_rbd_snap_list() memory leak when no snapshots List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi , qemu-devel@nongnu.org Cc: Kevin Wolf , Josh Durgin , qemu-stable@nongnu.org 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 Ping for 1.6.1 > --- > 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 =3D g_malloc(sizeof(*snaps) * max_snaps); > snap_count =3D rbd_snap_list(s->image, snaps, &max_snaps); > - if (snap_count < 0) { > + if (snap_count <=3D 0) { > g_free(snaps); > } > } while (snap_count =3D=3D -ERANGE); > -- = > 1.8.3.1