virtio-gpu: fix memory leak in resource attach backing
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
@@ -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
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.Signed-off-by Li Qiang <[email protected]>--- hw/display/virtio-gpu.c | 5 +++++ 1 file changed, 5 insertions(+)hw/display/virtio-gpu.c +0
-0
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
-1ret =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
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.Signed-off-by Li Qiang <[email protected]>--- hw/display/virtio-gpu.c | 5 +++++ 1 file changed, 5 insertions(+)hw/display/virtio-gpu.c +0
-0@@ -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
-0ret = virtio_gpu_create_mapping_iov(&ab, cmd, &res->addrs,
&res->iov);Quoted 6 lines
hw/display/virtio-gpu.c +0
-1if (ret !=0 ) { cmd->error =VIRTIO_GPU_RESP_ERR_UNSPEC ; --1.8.3.1
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