qcow2: Fix memory leaks in error cases
This fixes memory leaks that may be caused by I/O errors during L1 table growth
(can happen during save_vm) and in qemu-img check.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c
index 750abe3..c9e7bbd 100644
--- a/block/qcow2-cluster.c
+++ b/block/qcow2-cluster.c
@@ -70,7 +70,7 @@
ret = qcow2_cache_flush(bs, s->refcount_block_cache);
if (ret < 0) {
- return ret;
+ goto fail;
}
BLKDBG_EVENT(bs->file, BLKDBG_L1_GROW_WRITE_TABLE);