From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:34498) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXVm8-0003N7-NN for qemu-devel@nongnu.org; Thu, 24 May 2012 07:00:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SXVly-00073X-TN for qemu-devel@nongnu.org; Thu, 24 May 2012 07:00:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55720) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SXVly-0006zR-Kp for qemu-devel@nongnu.org; Thu, 24 May 2012 07:00:02 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id q4OB00v5026758 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Thu, 24 May 2012 07:00:00 -0400 From: Kevin Wolf Date: Thu, 24 May 2012 12:59:57 +0200 Message-Id: <1337857197-5496-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] qcow2: Check qcow2_alloc_clusters_at() return value List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com When using qcow2_alloc_clusters_at(), the cluster allocation code checked the wrong variable for an error code. Signed-off-by: Kevin Wolf --- block/qcow2-cluster.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 2e02241..75c0c0c 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -761,7 +761,6 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, uint64_t *host_offset, unsigned int *nb_clusters) { BDRVQcowState *s = bs->opaque; - int64_t cluster_offset; QCowL2Meta *old_alloc; trace_qcow2_do_alloc_clusters_offset(qemu_coroutine_self(), guest_offset, @@ -807,17 +806,17 @@ static int do_alloc_cluster_offset(BlockDriverState *bs, uint64_t guest_offset, /* Allocate new clusters */ trace_qcow2_cluster_alloc_phys(qemu_coroutine_self()); if (*host_offset == 0) { + int64_t cluster_offset; cluster_offset = qcow2_alloc_clusters(bs, *nb_clusters * s->cluster_size); + return (cluster_offset >= 0) ? 0 : cluster_offset; } else { - cluster_offset = *host_offset; - *nb_clusters = qcow2_alloc_clusters_at(bs, cluster_offset, *nb_clusters); - } - - if (cluster_offset < 0) { - return cluster_offset; + int ret = qcow2_alloc_clusters_at(bs, *host_offset, *nb_clusters); + if (ret < 0) { + return ret; + } + *nb_clusters = ret; + return 0; } - *host_offset = cluster_offset; - return 0; } /* -- 1.7.6.5