From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:42192) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbBxI-0000YU-6r for qemu-devel@nongnu.org; Thu, 15 Dec 2011 09:06:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RbBxB-0004dp-V1 for qemu-devel@nongnu.org; Thu, 15 Dec 2011 09:06:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47840) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RbBxB-0004dH-GG for qemu-devel@nongnu.org; Thu, 15 Dec 2011 09:06:33 -0500 From: Kevin Wolf Date: Thu, 15 Dec 2011 15:09:23 +0100 Message-Id: <1323958169-8333-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1323958169-8333-1-git-send-email-kwolf@redhat.com> References: <1323958169-8333-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 08/14] rbd: always set out parameter in qemu_rbd_snap_list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Josh Durgin The caller expects psn_tab to be NULL when there are no snapshots or an error occurs. This results in calling g_free on an invalid address. Reported-by: Oliver Francke Signed-off-by: Josh Durgin Signed-off-by: Kevin Wolf --- block/rbd.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-) diff --git a/block/rbd.c b/block/rbd.c index 312584a..7a2384c 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -805,7 +805,7 @@ static int qemu_rbd_snap_list(BlockDriverState *bs, } while (snap_count == -ERANGE); if (snap_count <= 0) { - return snap_count; + goto done; } sn_tab = g_malloc0(snap_count * sizeof(QEMUSnapshotInfo)); @@ -824,6 +824,7 @@ static int qemu_rbd_snap_list(BlockDriverState *bs, } rbd_snap_list_end(snaps); + done: *psn_tab = sn_tab; return snap_count; } -- 1.7.6.4