From 41fdddce05d929d7a87394a054cedb7c4f56d36d Mon Sep 17 00:00:00 2001 From: Kevin Wolf <kwolf@redhat.com> Date: Thu, 21 Jan 2010 14:03:04 -0200 Subject: [PATCH 06/10] qcow2: Fix error handling in grow_refcount_table RH-Author: Kevin Wolf <kwolf@redhat.com> Message-id: <1264082588-10273-7-git-send-email-kwolf@redhat.com> Patchwork-id: 6515 O-Subject: [RHEL-5.5 KVM PATCH 06/10] qcow2: Fix error handling in grow_refcount_table Bugzilla: 537077 RH-Acked-by: Christoph Hellwig <chellwig@redhat.com> RH-Acked-by: Juan Quintela <quintela@redhat.com> RH-Acked-by: Gleb Natapov <gleb@redhat.com> RH-Acked-by: Markus Armbruster <armbru@redhat.com> Bugzilla: 537077 Upstream status: Submitted Return the appropriate error code instead of -EIO. Signed-off-by: Kevin Wolf <kwolf@redhat.com> --- qemu/block-qcow2.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) Signed-off-by: Eduardo Habkost <ehabkost@redhat.com> --- qemu/block-qcow2.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-) diff --git a/qemu/block-qcow2.c b/qemu/block-qcow2.c index 07a401f..e0d60b7 100644 --- a/qemu/block-qcow2.c +++ b/qemu/block-qcow2.c @@ -2673,9 +2673,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; @@ -2688,7 +2691,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