Received: from eggs.gnu.org ([2001:4830:134:3::10]:49165) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIKu6-0002i3-Dp for qemu-devel@nongnu.org; Fri, 15 Aug 2014 13:03:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XIKu0-000757-Ae for qemu-devel@nongnu.org; Fri, 15 Aug 2014 13:03:02 -0400 Received: from mx1.redhat.com ([209.132.183.28]:65362) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XIKu0-00074s-2C for qemu-devel@nongnu.org; Fri, 15 Aug 2014 13:02:56 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s7FH2rfm013489 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Fri, 15 Aug 2014 13:02:53 -0400 From: Stefan Hajnoczi Date: Fri, 15 Aug 2014 18:02:46 +0100 Message-Id: <1408122166-8526-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PATCH] qcow2: fix new_blocks double-free in alloc_refcount_block() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi Commit de82815db1c89da058b7fb941dab137d6d9ab738 ("qcow2: Handle failure for potentially large allocations") introduced a double-free of new_blocks in the alloc_refcount_block() error path. The qemu-iotests qcow2 026 test case was failing because qemu-io segfaulted. Make sure new_blocks is NULL after we free it the first time. Reviewed-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi --- block/qcow2-refcount.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index d60e2fe..3b77470 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -381,6 +381,7 @@ static int alloc_refcount_block(BlockDriverState *bs, ret = bdrv_pwrite_sync(bs->file, meta_offset, new_blocks, blocks_clusters * s->cluster_size); g_free(new_blocks); + new_blocks = NULL; if (ret < 0) { goto fail_table; } -- 1.9.3