Framebuffer memory which was mmap() is being free() at the shutdown
of the guest, leading to glibc errors.

Signed-off-by: Sasha Levin <[email protected]>
---
 tools/kvm/framebuffer.c             |    3 ++-
 tools/kvm/hw/vesa.c                 |    1 +
 tools/kvm/include/kvm/framebuffer.h |    1 +
 3 files changed, 4 insertions(+), 1 deletions(-)

diff --git a/tools/kvm/framebuffer.c b/tools/kvm/framebuffer.c
index 1e35496..b6eb1ac 100644
--- a/tools/kvm/framebuffer.c
+++ b/tools/kvm/framebuffer.c
@@ -3,6 +3,7 @@
 #include <linux/kernel.h>
 #include <linux/list.h>
 #include <stdlib.h>
+#include <sys/mman.h>
 
 static LIST_HEAD(framebuffers);
 
@@ -62,6 +63,6 @@ void fb__stop(void)
        struct framebuffer *fb;
 
        list_for_each_entry(fb, &framebuffers, node) {
-               free(fb->mem);
+               munmap(fb->mem, fb->mem_size);
        }
 }
diff --git a/tools/kvm/hw/vesa.c b/tools/kvm/hw/vesa.c
index 71322fc..032e630 100644
--- a/tools/kvm/hw/vesa.c
+++ b/tools/kvm/hw/vesa.c
@@ -70,6 +70,7 @@ struct framebuffer *vesa__init(struct kvm *kvm)
                .depth                  = VESA_BPP,
                .mem                    = mem,
                .mem_addr               = VESA_MEM_ADDR,
+               .mem_size               = VESA_MEM_SIZE,
        };
        return fb__register(&vesafb);
 }
diff --git a/tools/kvm/include/kvm/framebuffer.h 
b/tools/kvm/include/kvm/framebuffer.h
index d28dadb..b66d0ba 100644
--- a/tools/kvm/include/kvm/framebuffer.h
+++ b/tools/kvm/include/kvm/framebuffer.h
@@ -20,6 +20,7 @@ struct framebuffer {
        u8                              depth;
        char                            *mem;
        u64                             mem_addr;
+       u64                             mem_size;
 
        unsigned long                   nr_targets;
        struct fb_target_operations     *targets[FB_MAX_TARGETS];
-- 
1.7.5.3

--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to