summaryrefslogtreecommitdiff
path: root/dump.c
diff options
context:
space:
mode:
authorPeter Maydell <peter.maydell@linaro.org>2014-08-19 10:30:36 +0100
committerPeter Maydell <peter.maydell@linaro.org>2014-08-19 10:30:36 +0100
commit8e6e2c2ae7a81f625cf1cb320891d5270e277548 (patch)
tree7aeba6994e047857dbccb3d14f0e67e8015112f5 /dump.c
parent073fd73e566c711f5c0cdaa300fdd1a3c8e7faa0 (diff)
parentb3dd1b8c295636e64ceb14cdc4db6420d7319e38 (diff)
downloadqemu-8e6e2c2ae7a81f625cf1cb320891d5270e277548.tar.gz
Merge remote-tracking branch 'remotes/qmp-unstable/queue/qmp' into staging
* remotes/qmp-unstable/queue/qmp: monitor: fix use after free dump.c: Fix memory leak issue in cleanup processing for dump_init() monitor: Remove hardcoded watchdog event names Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'dump.c')
-rw-r--r--dump.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/dump.c b/dump.c
index ce646bcc51..71d3e946e6 100644
--- a/dump.c
+++ b/dump.c
@@ -71,18 +71,14 @@ uint64_t cpu_to_dump64(DumpState *s, uint64_t val)
static int dump_cleanup(DumpState *s)
{
- int ret = 0;
-
guest_phys_blocks_free(&s->guest_phys_blocks);
memory_mapping_list_free(&s->list);
- if (s->fd != -1) {
- close(s->fd);
- }
+ close(s->fd);
if (s->resume) {
vm_start();
}
- return ret;
+ return 0;
}
static void dump_error(DumpState *s, const char *reason)
@@ -1499,6 +1495,8 @@ static int dump_init(DumpState *s, int fd, bool has_format,
s->begin = begin;
s->length = length;
+ memory_mapping_list_init(&s->list);
+
guest_phys_blocks_init(&s->guest_phys_blocks);
guest_phys_blocks_append(&s->guest_phys_blocks);
@@ -1526,7 +1524,6 @@ static int dump_init(DumpState *s, int fd, bool has_format,
}
/* get memory mapping */
- memory_mapping_list_init(&s->list);
if (paging) {
qemu_get_guest_memory_mapping(&s->list, &s->guest_phys_blocks, &err);
if (err != NULL) {
@@ -1622,12 +1619,7 @@ static int dump_init(DumpState *s, int fd, bool has_format,
return 0;
cleanup:
- guest_phys_blocks_free(&s->guest_phys_blocks);
-
- if (s->resume) {
- vm_start();
- }
-
+ dump_cleanup(s);
return -1;
}