Skip to contentSkip to conversation

fix memory leak in virtio_gpu_resource_destroy

PATCH In review Li Qiang 2 participants 4 messages Nov 24, 2016 – Nov 28, 2016

lore
Share & tools
lore
author
#2 lore raw

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

In reply to 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.

---
 hw/display/virtio-gpu.c | 1 +
 1 file changed, 1 insertion(+)
hw/display/virtio-gpu.c +1 -0
index cc725a6..98dadf2 100644
@@ -360,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

Li Qiang

author
#0 lore raw

cover fix memory leak in virtio_gpu_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 patchset address this.

Li Qiang (2):
virtio-gpu: add declaration for virtio_gpu_cleanup_mapping function
virtio-gpu: call cleanup mapping function in resource destroy

 hw/display/virtio-gpu.c | 3 +++
 1 file changed, 3 insertions(+)
Signature · 1 line
1.8.3.1
author
#1 lore raw

PATCH 1/2 virtio-gpu: add declaration for virtio_gpu_cleanup_mapping function

The virtio_gpu_resource_destroy function is before the definition of the cleanup mapping function and it should call this cleanup mapping function, so we should add a declaration for it.

---
 hw/display/virtio-gpu.c | 2 ++
 1 file changed, 2 insertions(+)
hw/display/virtio-gpu.c +2 -0
index 60bce94..cc725a6 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, ...)                     \
Signature · 1 line
1.8.3.1
Reviewed-by on v1 2/2
#3 lore raw

Re: [Qemu-devel] [PATCH 2/2] virtio-gpu: call cleanup mapping function in resource destroy

In reply to Li Qiang

Hi

Quoted 5 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.

That looks correct to me.

Please squash patch 1 (no reason for it to be split).

Quoted 21 lines
---
 hw/display/virtio-gpu.c | 1 +
 1 file changed, 1 insertion(+)
hw/display/virtio-gpu.c +1 -0
index cc725a6..98dadf2 100644
@@ -360,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