From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NXbAP-00076Y-F9 for qemu-devel@nongnu.org; Wed, 20 Jan 2010 09:04:17 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1NXbAI-0006zJ-Tj for qemu-devel@nongnu.org; Wed, 20 Jan 2010 09:04:16 -0500 Received: from [199.232.76.173] (port=43301 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NXbAI-0006yd-B2 for qemu-devel@nongnu.org; Wed, 20 Jan 2010 09:04:10 -0500 Received: from mx1.redhat.com ([209.132.183.28]:46571) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NXbAH-0003M3-Ov for qemu-devel@nongnu.org; Wed, 20 Jan 2010 09:04:09 -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 o0KE48lJ008988 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Wed, 20 Jan 2010 09:04:08 -0500 From: Kevin Wolf Date: Wed, 20 Jan 2010 15:03:03 +0100 Message-Id: <1263996186-6623-7-git-send-email-kwolf@redhat.com> In-Reply-To: <1263996186-6623-1-git-send-email-kwolf@redhat.com> References: <1263996186-6623-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH v2 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.5.2