diff options
author | Kevin Wolf <kwolf@redhat.com> | 2011-06-01 10:50:00 +0200 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2011-06-08 11:56:40 +0200 |
commit | 80fa3341a70151d250be92ae900e3c1580817540 (patch) | |
tree | 890de6480719897bcd67dbd1e9a2c346401a922e /block/qcow2-refcount.c | |
parent | 30cdc48cc8c9ad28e1b95460021d0c121b3ed4f4 (diff) |
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>
Diffstat (limited to 'block/qcow2-refcount.c')
-rw-r--r-- | 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 d62dc1c091..ac95b88fe1 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1086,7 +1086,7 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res) ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters, s->l1_table_offset, s->l1_size, 1); if (ret < 0) { - return ret; + goto fail; } /* snapshots */ @@ -1095,7 +1095,7 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res) ret = check_refcounts_l1(bs, res, refcount_table, nb_clusters, sn->l1_table_offset, sn->l1_size, 0); if (ret < 0) { - return ret; + goto fail; } } inc_refcounts(bs, res, refcount_table, nb_clusters, @@ -1159,8 +1159,11 @@ int qcow2_check_refcounts(BlockDriverState *bs, BdrvCheckResult *res) } } + ret = 0; + +fail: qemu_free(refcount_table); - return 0; + return ret; } |