Received: from eggs.gnu.org ([2001:4830:134:3::10]:43747) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XVyif-0006nV-DK for qemu-devel@nongnu.org; Mon, 22 Sep 2014 04:11:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XVyiT-00065z-6N for qemu-devel@nongnu.org; Mon, 22 Sep 2014 04:11:37 -0400 From: Michael Tokarev Date: Mon, 22 Sep 2014 12:11:15 +0400 Message-Id: <1411373477-16938-8-git-send-email-mjt@msgid.tls.msk.ru> In-Reply-To: <1411373477-16938-1-git-send-email-mjt@tls.msk.ru> References: <1411373477-16938-1-git-send-email-mjt@tls.msk.ru> Subject: [Qemu-devel] [PULL 7/9] block: allow creation of fixed vhdx images List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, Adelina Tuvenie , Adelina Tuvenie , Michael Tokarev From: Adelina Tuvenie When trying to create a fixed vhd image qemu-img will return the following error: qemu-img: test.vhdx: Could not create image: Cannot allocate memory This happens because of a incorrect check in vhdx.c. Specifficaly, in vhdx_create_bat(), after allocating memory for the BAT entry, there is a check to determine if the allocation was unsuccsessful. The error comes from the fact that it checks if s->bat isn't NULL, which is true in case of succsessful allocation, and exits with error ENOMEM. Signed-off-by: Adelina Tuvenie Acked-by: Kevin Wolf Signed-off-by: Michael Tokarev --- block/vhdx.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/vhdx.c b/block/vhdx.c index 796b7bd..5bf292e 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1593,7 +1593,7 @@ static int vhdx_create_bat(BlockDriverState *bs, BDRVVHDXState *s, bdrv_has_zero_init(bs) == 0) { /* for a fixed file, the default BAT entry is not zero */ s->bat = g_try_malloc0(length); - if (length && s->bat != NULL) { + if (length && s->bat == NULL) { ret = -ENOMEM; goto exit; } -- 1.7.10.4