From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NWqTO-0006kA-0m for qemu-devel@nongnu.org; Mon, 18 Jan 2010 07:12:46 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NWqTI-0006hF-Mx for qemu-devel@nongnu.org; Mon, 18 Jan 2010 07:12:45 -0500 Received: from [199.232.76.173] (port=51040 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NWqTI-0006h9-EP for qemu-devel@nongnu.org; Mon, 18 Jan 2010 07:12:40 -0500 Received: from mx1.redhat.com ([209.132.183.28]:13646) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NWqTI-0001bi-3L for qemu-devel@nongnu.org; Mon, 18 Jan 2010 07:12:40 -0500 Received: from int-mx05.intmail.prod.int.phx2.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.18]) by mx1.redhat.com (8.13.8/8.13.8) with ESMTP id o0ICCd4A021660 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 18 Jan 2010 07:12:39 -0500 From: Kevin Wolf Date: Mon, 18 Jan 2010 13:11:32 +0100 Message-Id: <1263816696-24122-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1263816696-24122-1-git-send-email-kwolf@redhat.com> References: <1263816696-24122-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 06/10] qcow2: Fix error handling in grow_refcount_table List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf Return the appropriate error code instead of -EIO. Signed-off-by: Kevin Wolf --- block/qcow2-refcount.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 3a2d44a..6f449c6 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -168,9 +168,12 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size) cpu_to_be64w((uint64_t*)data, table_offset); cpu_to_be32w((uint32_t*)(data + 8), refcount_table_clusters); - if (bdrv_pwrite(s->hd, offsetof(QCowHeader, refcount_table_offset), - data, sizeof(data)) != sizeof(data)) + ret = bdrv_pwrite(s->hd, offsetof(QCowHeader, refcount_table_offset), + data, sizeof(data)); + if (ret != sizeof(data)) { goto fail; + } + qemu_free(s->refcount_table); old_table_offset = s->refcount_table_offset; old_table_size = s->refcount_table_size; @@ -183,7 +186,7 @@ static int grow_refcount_table(BlockDriverState *bs, int min_size) return 0; fail: qemu_free(new_table); - return -EIO; + return ret < 0 ? ret : -EIO; } -- 1.6.2.5