diff options
| author | Chen Gang | 2014-08-03 17:28:56 +0200 |
|---|---|---|
| committer | Luiz Capitulino | 2014-08-18 20:39:10 +0200 |
| commit | 2928207ac1bb2751a1554ea0f9a9641179f51488 (patch) | |
| tree | 3332eed463807d58996993aa9202c4cac6c5a371 /dump.c | |
| parent | monitor: Remove hardcoded watchdog event names (diff) | |
| download | qemu-2928207ac1bb2751a1554ea0f9a9641179f51488.tar.gz qemu-2928207ac1bb2751a1554ea0f9a9641179f51488.tar.xz qemu-2928207ac1bb2751a1554ea0f9a9641179f51488.zip | |
dump.c: Fix memory leak issue in cleanup processing for dump_init()
In dump_init(), when failure occurs, need notice about 'fd' and memory
mapping. So call dump_cleanup() for it (need let all initializations at
front).
Also simplify dump_cleanup(): remove redundant 'ret' and redundant 'fd'
checking.
Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
Diffstat (limited to 'dump.c')
| -rw-r--r-- | dump.c | 18 |
1 files changed, 5 insertions, 13 deletions
@@ -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; } |
