Skip to contentSkip to conversation

virtio-gpu: fix memory leak in resource attach backing

PATCH In review Li Qiang 3 participants 4 messages Dec 29, 2016 – Jan 3, 2017

lore
Share & tools
lore

Li Qiang

author
#0 lore raw

PATCH 1/1 virtio-gpu: fix memory leak in resource attach backing

In the resource attach backing function, everytime it will allocate 'res->iov' thus can leading a memory leak. This patch avoid this.

---
 hw/display/virtio-gpu.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/display/virtio-gpu.c +5 -0
index 5f32e1a..045f296 100644
@@ -705,6 +705,11 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g,
         return;
     }
 
+    if (res->iov) {
+        cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
+        return;
+    }
+
     ret = virtio_gpu_create_mapping_iov(&ab, cmd, &res->addrs, &res->iov);
     if (ret != 0) {
         cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
Signature · 1 line
1.8.3.1
#1 lore raw

Hi

----- Original Message -----

Quoted 14 lines

In the resource attach backing function, everytime it will allocate 'res->iov' thus can leading a memory leak. This patch avoid this.

---
 hw/display/virtio-gpu.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/display/virtio-gpu.c +0 -0
index 5f32e1a..045f296 100644

hw/display/virtio-gpu.c virtio_gpu_resource_attach_backing(VirtIOGPU *g, · line 712

Quoted 8 lines
hw/display/virtio-gpu.c +5 -0
@@ -705,6 +705,11 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g,
         return;
     }
 
+    if (res->iov) {
+        cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
+        return;
+    }
+

I think I would rather return an error in the library for this case.

Quoted 7 lines
hw/display/virtio-gpu.c +0 -1
     ret = virtio_gpu_create_mapping_iov(&ab, cmd, &res->addrs, &res->iov);
     if (ret != 0) {
         cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
--

1.8.3.1

author
#2 lore raw

2016-12-29 22:57 GMT+08:00 Marc-André Lureau <[email protected]>:

Quoted 20 lines

Hi

----- Original Message -----

Quoted 17 lines

In the resource attach backing function, everytime it will allocate 'res->iov' thus can leading a memory leak. This patch avoid this.

---
 hw/display/virtio-gpu.c | 5 +++++
 1 file changed, 5 insertions(+)
hw/display/virtio-gpu.c +0 -0
index 5f32e1a..045f296 100644
@@ -705,6 +705,11 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g,
         return;
     }
 
Quoted 9 lines

hw/display/virtio-gpu.c virtio_gpu_resource_attach_backing(VirtIOGPU *g, · line 712

Quoted 5 lines
hw/display/virtio-gpu.c +5 -0
+    if (res->iov) {
+        cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
+        return;
+    }
+

I think I would rather return an error in the library for this case.

IIUC Do you mean virglrenderer library? There is no related to this library.

Thanks.

Quoted 9 lines

hw/display/virtio-gpu.c virtio_gpu_resource_attach_backing(VirtIOGPU *g, · line 713

Quoted 1 line
hw/display/virtio-gpu.c +0 -0
     ret = virtio_gpu_create_mapping_iov(&ab, cmd, &res->addrs,

&res->iov);

Quoted 6 lines
hw/display/virtio-gpu.c +0 -1
     if (ret != 0) {
         cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
--

1.8.3.1

#3 lore raw
In reply to Marc-André Lureau
Quoted 7 lines

hw/display/virtio-gpu.c virtio_gpu_resource_attach_backing(VirtIOGPU *g, · line 712

Quoted 5 lines
hw/display/virtio-gpu.c +5 -0
+    if (res->iov) {
+        cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
+        return;
+    }
+

I think I would rather return an error in the library for this case.

-ENOLIBRARY ;)

This is the 2d mode code, so virglrenderer isn't involved at all.

Added patch to the queue (and the 3d one too).

thanks,
Gerd