From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48883) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoVeZ-0002Eg-OO for qemu-devel@nongnu.org; Wed, 12 Nov 2014 06:00:05 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XoVeT-0006mq-JV for qemu-devel@nongnu.org; Wed, 12 Nov 2014 05:59:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:36275) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XoVeT-0006ml-Cd for qemu-devel@nongnu.org; Wed, 12 Nov 2014 05:59:53 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sACAxqtc002890 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Wed, 12 Nov 2014 05:59:52 -0500 From: Paolo Bonzini Date: Wed, 12 Nov 2014 11:59:49 +0100 Message-Id: <1415789989-13489-1-git-send-email-pbonzini@redhat.com> Subject: [Qemu-devel] [PATCH] vhdx: fix g_try_malloc0 thinko List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, jcody@redhat.com, stefanha@redhat.com Spotted while looking at Coverity reports (though not found by Coverity itself). Signed-off-by: Paolo Bonzini --- block/qcow2-snapshot.c | 2 +- block/vhdx.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2-snapshot.c b/block/qcow2-snapshot.c index f52d7fd..27d3bc1 100644 --- a/block/qcow2-snapshot.c +++ b/block/qcow2-snapshot.c @@ -465,7 +465,7 @@ int qcow2_snapshot_goto(BlockDriverState *bs, const char *snapshot_id) BDRVQcowState *s = bs->opaque; QCowSnapshot *sn; int i, snapshot_index; - int cur_l1_bytes, sn_l1_bytes; + size_t cur_l1_bytes, sn_l1_bytes; int ret; uint64_t *sn_l1_table = NULL; diff --git a/block/vhdx.c b/block/vhdx.c index 87c99fc..bd1e403 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; } -- 2.1.0