[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 01/40] qemu-img: eliminate memory leak
From: |
Kevin Wolf |
Subject: |
[Qemu-devel] [PULL 01/40] qemu-img: eliminate memory leak |
Date: |
Mon, 14 Mar 2016 18:37:02 +0100 |
From: Paolo Bonzini <address@hidden>
Not particularly important since qemu-img exits immediately after
calling img_rebase, but easily fixed. Coverity says thanks.
Signed-off-by: Paolo Bonzini <address@hidden>
Reviewed-by: Alberto Garcia <address@hidden>
Signed-off-by: Kevin Wolf <address@hidden>
---
qemu-img.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/qemu-img.c b/qemu-img.c
index 2edb139..3103150 100644
--- a/qemu-img.c
+++ b/qemu-img.c
@@ -2775,6 +2775,8 @@ static int img_snapshot(int argc, char **argv)
static int img_rebase(int argc, char **argv)
{
BlockBackend *blk = NULL, *blk_old_backing = NULL, *blk_new_backing = NULL;
+ uint8_t *buf_old = NULL;
+ uint8_t *buf_new = NULL;
BlockDriverState *bs = NULL;
char *filename;
const char *fmt, *cache, *src_cache, *out_basefmt, *out_baseimg;
@@ -2957,8 +2959,6 @@ static int img_rebase(int argc, char **argv)
int64_t new_backing_num_sectors = 0;
uint64_t sector;
int n;
- uint8_t * buf_old;
- uint8_t * buf_new;
float local_progress = 0;
buf_old = blk_blockalign(blk, IO_BUF_SIZE);
@@ -3070,9 +3070,6 @@ static int img_rebase(int argc, char **argv)
}
qemu_progress_print(local_progress, 100);
}
-
- qemu_vfree(buf_old);
- qemu_vfree(buf_new);
}
/*
@@ -3108,6 +3105,8 @@ out:
blk_unref(blk_old_backing);
blk_unref(blk_new_backing);
}
+ qemu_vfree(buf_old);
+ qemu_vfree(buf_new);
blk_unref(blk);
if (ret) {
--
1.8.3.1
- [Qemu-devel] [PULL 00/40] Block patches, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 03/40] block/qapi: Factor out bdrv_query_bds_stats(), Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 01/40] qemu-img: eliminate memory leak,
Kevin Wolf <=
- [Qemu-devel] [PULL 02/40] block/qapi: Factor out bdrv_query_blk_stats(), Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 04/40] block/qapi: Include empty drives in query-blockstats, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 05/40] block/vpc: choose size calculation method based on creator_app field, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 09/40] docs: fix invalid node name in qmp event, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 11/40] quorum: modify vote rules for flush operation, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 06/40] block/vpc: tests for auto-detecting VPC and Hyper-V VHD images, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 10/40] qmp event: Refactor QUORUM_REPORT_BAD, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 08/40] block/vpc: add tests for image creation force_size parameter, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 07/40] block/vpc: give option to force the current_size field in .bdrv_create, Kevin Wolf, 2016/03/14
- [Qemu-devel] [PULL 12/40] blockdev: Snapshotting must not open second instance of old top, Kevin Wolf, 2016/03/14