aboutsummaryrefslogtreecommitdiff
path: root/block/vmdk.c
diff options
context:
space:
mode:
authorFam Zheng <famcool@gmail.com>2011-09-19 10:26:42 +0800
committerKevin Wolf <kwolf@redhat.com>2011-09-20 12:27:43 +0200
commitb3c0bfb6f949d8f1c97f390f951c0bab3e703810 (patch)
tree74cf07182169308d3a59c84ec1fd5baed32cc50a /block/vmdk.c
parent7285477ab11831b1cf56e45878a89170dd06d9b9 (diff)
downloadqemu-b3c0bfb6f949d8f1c97f390f951c0bab3e703810.zip
qemu-b3c0bfb6f949d8f1c97f390f951c0bab3e703810.tar.gz
qemu-b3c0bfb6f949d8f1c97f390f951c0bab3e703810.tar.bz2
VMDK: fix leak of extent_file
Release extent_file on error in vmdk_parse_extents. Added closing files in freeing extents. Signed-off-by: Fam Zheng <famcool@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Diffstat (limited to 'block/vmdk.c')
-rw-r--r--block/vmdk.c14
1 files changed, 10 insertions, 4 deletions
diff --git a/block/vmdk.c b/block/vmdk.c
index 6c8edfc..5d16ec4 100644
--- a/block/vmdk.c
+++ b/block/vmdk.c
@@ -179,11 +179,16 @@ static void vmdk_free_extents(BlockDriverState *bs)
{
int i;
BDRVVmdkState *s = bs->opaque;
+ VmdkExtent *e;
for (i = 0; i < s->num_extents; i++) {
- g_free(s->extents[i].l1_table);
- g_free(s->extents[i].l2_cache);
- g_free(s->extents[i].l1_backup_table);
+ e = &s->extents[i];
+ g_free(e->l1_table);
+ g_free(e->l2_cache);
+ g_free(e->l1_backup_table);
+ if (e->file != bs->file) {
+ bdrv_delete(e->file);
+ }
}
g_free(s->extents);
}
@@ -619,12 +624,13 @@ static int vmdk_open_desc_file(BlockDriverState *bs, int flags,
s->desc_offset = 0;
ret = vmdk_parse_extents(buf, bs, bs->file->filename);
if (ret) {
+ vmdk_free_extents(bs);
return ret;
}
/* try to open parent images, if exist */
if (vmdk_parent_open(bs)) {
- g_free(s->extents);
+ vmdk_free_extents(bs);
return -EINVAL;
}
s->parent_cid = vmdk_read_cid(bs, 1);