diff options
author | Fam Zheng <famz@redhat.com> | 2014-05-28 11:38:58 +0800 |
---|---|---|
committer | Kevin Wolf <kwolf@redhat.com> | 2014-05-30 14:26:54 +0200 |
commit | c13959c745a7e4965c94d19e3153d2c44459906d (patch) | |
tree | 6f8f1743865c7cbd8bdd8f16ed10cdad3ad209e2 | |
parent | 675036e4dadd2426c93c54d7f7155f519eda53e6 (diff) | |
download | hqemu-c13959c745a7e4965c94d19e3153d2c44459906d.zip hqemu-c13959c745a7e4965c94d19e3153d2c44459906d.tar.gz |
vmdk: Fix local_err in vmdk_create
In vmdk_create and vmdk_create_extent, initialize local_err before using
it, and don't leak it on error.
Reported-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
-rw-r--r-- | block/vmdk.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/block/vmdk.c b/block/vmdk.c index 480ea37..2b38f61 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1534,7 +1534,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize, int ret, i; BlockDriverState *bs = NULL; VMDK4Header header; - Error *local_err; + Error *local_err = NULL; uint32_t tmp, magic, grains, gd_sectors, gt_size, gt_count; uint32_t *gd_buf = NULL; int gd_buf_size; @@ -1700,7 +1700,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options, { int idx = 0; BlockDriverState *new_bs = NULL; - Error *local_err; + Error *local_err = NULL; char *desc = NULL; int64_t total_size = 0, filesize; const char *adapter_type = NULL; @@ -1881,7 +1881,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options, } else { ret = bdrv_create_file(filename, options, &local_err); if (ret < 0) { - error_setg_errno(errp, -ret, "Could not create image file"); + error_propagate(errp, local_err); goto exit; } } @@ -1889,7 +1889,7 @@ static int vmdk_create(const char *filename, QEMUOptionParameter *options, ret = bdrv_open(&new_bs, filename, NULL, NULL, BDRV_O_RDWR | BDRV_O_PROTOCOL, NULL, &local_err); if (ret < 0) { - error_setg_errno(errp, -ret, "Could not write description"); + error_propagate(errp, local_err); goto exit; } ret = bdrv_pwrite(new_bs, desc_offset, desc, desc_len); |