Skip to contentSkip to conversation

virtio-gpu: call cleanup mapping function in resource destroy

PATCH In review Li Qiang 2 participants 3 messages Nov 29, 2016 – Dec 13, 2016

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 virtio-gpu: call cleanup mapping function in resource destroy

If the guest destroy the resource before detach banking, the 'iov' and 'addrs' field in resource is not freed thus leading memory leak issue. This patch avoid this.

---
 hw/display/virtio-gpu.c | 3 +++
 1 file changed, 3 insertions(+)
hw/display/virtio-gpu.c +3 -0
index 60bce94..98dadf2 100644
@@ -28,6 +28,8 @@
 static struct virtio_gpu_simple_resource*
 virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id);
 
+static void virtio_gpu_cleanup_mapping(struct virtio_gpu_simple_resource *res);
+
 #ifdef CONFIG_VIRGL
 #include <virglrenderer.h>
 #define VIRGL(_g, _virgl, _simple, ...)                     \
@@ -358,6 +360,7 @@ static void virtio_gpu_resource_destroy(VirtIOGPU *g,
                                         struct virtio_gpu_simple_resource *res)
 {
     pixman_image_unref(res->image);
+    virtio_gpu_cleanup_mapping(res);
     QTAILQ_REMOVE(&g->reslist, res, next);
     g_free(res);
 }
Signature · 1 line
1.8.3.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · Li Qiang

If the guest destroy the resource before detach banking, the 'iov' and 'addrs' field in resource is not freed thus leading memory leak issue. This patch avoid this.

---

Quoted 29 lines
 hw/display/virtio-gpu.c | 3 +++
 1 file changed, 3 insertions(+)
hw/display/virtio-gpu.c +2 -0
index 60bce94..98dadf2 100644
@@ -28,6 +28,8 @@
 static struct virtio_gpu_simple_resource*
 virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id);
 
+static void virtio_gpu_cleanup_mapping(struct virtio_gpu_simple_resource
 *res);
+
 #ifdef CONFIG_VIRGL
 #include <virglrenderer.h>

#define VIRGL(_g, _virgl, _simple, ...) \

hw/display/virtio-gpu.c +1 -0
@@ -358,6 +360,7 @@ static void virtio_gpu_resource_destroy(VirtIOGPU *g,
                                         struct virtio_gpu_simple_resource
 *res)
 {
     pixman_image_unref(res->image);
+    virtio_gpu_cleanup_mapping(res);
     QTAILQ_REMOVE(&g->reslist, res, next);
     g_free(res);

}
--
1.8.3.1

Quoted 1 line

--

Marc-André Lureau

author
#2 lore raw
In reply to Li Qiang

Ping!

2016-11-29 10:29 GMT+08:00 Li Qiang <[email protected]>:

Quoted 36 lines

If the guest destroy the resource before detach banking, the 'iov' and 'addrs' field in resource is not freed thus leading memory leak issue. This patch avoid this.

---
 hw/display/virtio-gpu.c | 3 +++
 1 file changed, 3 insertions(+)
hw/display/virtio-gpu.c +2 -0
index 60bce94..98dadf2 100644
@@ -28,6 +28,8 @@
 static struct virtio_gpu_simple_resource*
 virtio_gpu_find_resource(VirtIOGPU *g, uint32_t resource_id);
 
+static void virtio_gpu_cleanup_mapping(struct virtio_gpu_simple_resource
 *res);
+
 #ifdef CONFIG_VIRGL
 #include <virglrenderer.h>

#define VIRGL(_g, _virgl, _simple, ...) \

hw/display/virtio-gpu.c +1 -0
@@ -358,6 +360,7 @@ static void virtio_gpu_resource_destroy(VirtIOGPU *g,
                                         struct virtio_gpu_simple_resource
 *res)
 {
     pixman_image_unref(res->image);
+    virtio_gpu_cleanup_mapping(res);
     QTAILQ_REMOVE(&g->reslist, res, next);
     g_free(res);

}
--
1.8.3.1