diff options
author | Don Slutz <don.slutz@gmail.com> | 2015-11-30 17:11:04 -0500 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2015-12-02 12:01:43 +0100 |
commit | 55b4e80b047300e1512df02887b7448ba3786b62 (patch) | |
tree | 518baa57a8aa6ceaf698f39b0fa34c7873a1f2c0 /exec.c | |
parent | 9d7b969ea6d9663a94760c6c131481b366f4d38a (diff) | |
download | hqemu-55b4e80b047300e1512df02887b7448ba3786b62.zip hqemu-55b4e80b047300e1512df02887b7448ba3786b62.tar.gz |
exec: Stop using memory after free
memory_region_unref(mr) can free memory.
For example I got:
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f43280d4700 (LWP 4462)]
0x00007f43323283c0 in phys_section_destroy (mr=0x7f43259468b0)
at /home/don/xen/tools/qemu-xen-dir/exec.c:1023
1023 if (mr->subpage) {
(gdb) bt
at /home/don/xen/tools/qemu-xen-dir/exec.c:1023
at /home/don/xen/tools/qemu-xen-dir/exec.c:1034
at /home/don/xen/tools/qemu-xen-dir/exec.c:2205
(gdb) p mr
$1 = (MemoryRegion *) 0x7f43259468b0
And this change prevents this.
Signed-off-by: Don Slutz <Don.Slutz@Gmail.com>
Message-Id: <1448921464-21845-1-git-send-email-Don.Slutz@Gmail.com>
Cc: qemu-stable@nongnu.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'exec.c')
-rw-r--r-- | exec.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -1064,9 +1064,11 @@ static uint16_t phys_section_add(PhysPageMap *map, static void phys_section_destroy(MemoryRegion *mr) { + bool have_sub_page = mr->subpage; + memory_region_unref(mr); - if (mr->subpage) { + if (have_sub_page) { subpage_t *subpage = container_of(mr, subpage_t, iomem); object_unref(OBJECT(&subpage->iomem)); g_free(subpage); |