[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 10/12] qcow2: Fix memory leaks in error cases
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PATCH 10/12] qcow2: Fix memory leaks in error cases |
Date: |
Wed, 8 Jun 2011 15:48:28 +0200 |
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 <address@hidden>
---
block/qcow2-cluster.c | 2 +-
block/qcow2-refcount.c | 9 ++++++---
2 files changed, 7 insertions(+), 4 deletions(-)
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 @@ int qcow2_grow_l1_table(BlockDriverState *bs, int min_size,
bool exact_size)
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);
diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c
index d62dc1c..ac95b88 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;
}
--
1.7.5.2
- [Qemu-devel] [PULL 00/12] Block patches, Kevin Wolf, 2011/06/08
- [Qemu-devel] [PATCH 03/12] vmdk: fix endianness bugs, Kevin Wolf, 2011/06/08
- [Qemu-devel] [PATCH 04/12] block/raw-posix: use a character device if a block device is given, Kevin Wolf, 2011/06/08
- [Qemu-devel] [PATCH 08/12] rbd: check return values when scheduling aio, Kevin Wolf, 2011/06/08
- [Qemu-devel] [PATCH 02/12] block: clarify the meaning of BDRV_O_NOCACHE, Kevin Wolf, 2011/06/08
- [Qemu-devel] [PATCH 06/12] rbd: use the higher level librbd instead of just librados, Kevin Wolf, 2011/06/08
- [Qemu-devel] [PATCH 11/12] bdrv_img_create: Fix segfault, Kevin Wolf, 2011/06/08
- [Qemu-devel] [PATCH 07/12] rbd: allow configuration of rados from the rbd filename, Kevin Wolf, 2011/06/08
- [Qemu-devel] [PATCH 01/12] ide/core: Remove explicit setting of BM_STATUS_INT, Kevin Wolf, 2011/06/08
- [Qemu-devel] [PATCH 10/12] qcow2: Fix memory leaks in error cases,
Kevin Wolf <=
- [Qemu-devel] [PATCH 05/12] block/raw-posix: get right partition size, Kevin Wolf, 2011/06/08
- [Qemu-devel] [PATCH 09/12] rbd: Add bdrv_truncate implementation, Kevin Wolf, 2011/06/08
- [Qemu-devel] [PATCH 12/12] qemu-img create: Fix displayed default cluster size, Kevin Wolf, 2011/06/08
- Re: [Qemu-devel] [PULL 00/12] Block patches, Anthony Liguori, 2011/06/09