mvadkert / rpms / qemu

Forked from rpms/qemu 6 years ago
Clone
4d7edd7
From: Li Qiang <liq3ea@gmail.com>
4d7edd7
Date: Mon, 28 Nov 2016 21:29:25 -0500
4d7edd7
Subject: [PATCH] virtio-gpu: call cleanup mapping function in resource destroy
4d7edd7
MIME-Version: 1.0
4d7edd7
Content-Type: text/plain; charset=UTF-8
4d7edd7
Content-Transfer-Encoding: 8bit
4d7edd7
4d7edd7
If the guest destroy the resource before detach banking, the 'iov'
4d7edd7
and 'addrs' field in resource is not freed thus leading memory
4d7edd7
leak issue. This patch avoid this.
4d7edd7
4d7edd7
Signed-off-by: Li Qiang <liq3ea@gmail.com>
4d7edd7
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
4d7edd7
Message-id: 1480386565-10077-1-git-send-email-liq3ea@gmail.com
4d7edd7
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
4d7edd7
(cherry picked from commit b8e23926c568f2e963af39028b71c472e3023793)
4d7edd7
---
4d7edd7
 hw/display/virtio-gpu.c | 3 +++
4d7edd7
 1 file changed, 3 insertions(+)
4d7edd7
4d7edd7
diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
4d7edd7
index f41afc7..4ccc8bc 100644
4d7edd7
--- a/hw/display/virtio-gpu.c
4d7edd7
+++ b/hw/display/virtio-gpu.c
4d7edd7
@@ -23,6 +23,8 @@
4d7edd7
 static struct virtio_gpu_simple_resource*
4d7edd7
 virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id);
4d7edd7
 
4d7edd7
+static void virtio_gpu_cleanup_mapping(struct virtio_gpu_simple_resource *res);
4d7edd7
+
4d7edd7
 #ifdef CONFIG_VIRGL
4d7edd7
 #include "virglrenderer.h"
4d7edd7
 #define VIRGL(_g, _virgl, _simple, ...)                     \
4d7edd7
@@ -349,6 +351,7 @@ static void virtio_gpu_resource_destroy(VirtIOGPU *g,
4d7edd7
                                         struct virtio_gpu_simple_resource *res)
4d7edd7
 {
4d7edd7
     pixman_image_unref(res->image);
4d7edd7
+    virtio_gpu_cleanup_mapping(res);
4d7edd7
     QTAILQ_REMOVE(&g->reslist, res, next);
4d7edd7
     g_free(res);
4d7edd7
 }