From 81c0887a9724543b7bb07ec5e2e13bee113ed506 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Tue, 2 Feb 2010 16:40:25 -0200 Subject: [PATCH 07/14] qcow2: Fix error handling in grow_refcount_table RH-Author: Kevin Wolf Message-id: <1265128829-26978-8-git-send-email-kwolf@redhat.com> Patchwork-id: 6846 O-Subject: [RHEL-6 KVM PATCH v2 07/11] qcow2: Fix error handling in grow_refcount_table Bugzilla: 560623 RH-Acked-by: Markus Armbruster RH-Acked-by: Gleb Natapov RH-Acked-by: Juan Quintela Bugzilla: 560623 Upstream commit: f2b7c8b Return the appropriate error code instead of -EIO. Signed-off-by: Kevin Wolf Signed-off-by: Anthony Liguori Signed-off-by: Kevin Wolf --- block/qcow2-refcount.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) Signed-off-by: Eduardo Habkost --- 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 54b19f8..9fb2838 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.3.rc4.29.g8146