diff mbox

virtio-gpu: fix memory leak in set scanout

Message ID 5884626f.5b2f6b0a.1bfff.3037@mx.google.com (mailing list archive)
State New, archived
Headers show

Commit Message

Li Qiang Jan. 22, 2017, 7:42 a.m. UTC
From: Li Qiang <liqiang6-s@360.cn>

In virtio_gpu_set_scanout function, when creating the 'rect'
its refcount is set to 2, by pixman_image_create_bits and
qemu_create_displaysurface_pixman function. This can lead 
a memory leak issues. This patch avoid this issue.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
---
 hw/display/virtio-gpu.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Marc-André Lureau Jan. 23, 2017, 9:09 a.m. UTC | #1
On Sun, Jan 22, 2017 at 11:43 AM Li Qiang <liq3ea@gmail.com> wrote:

> From: Li Qiang <liqiang6-s@360.cn>
>
> In virtio_gpu_set_scanout function, when creating the 'rect'
> its refcount is set to 2, by pixman_image_create_bits and
> qemu_create_displaysurface_pixman function. This can lead
> a memory leak issues. This patch avoid this issue.
>
> Signed-off-by: Li Qiang <liqiang6-s@360.cn>
>


Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>



> ---
>  hw/display/virtio-gpu.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index 7a15c61..4aecea3 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -608,6 +608,7 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g,
>              cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
>              return;
>          }
> +        pixman_image_unref(rect);
>          dpy_gfx_replace_surface(g->scanout[ss.scanout_id].con,
> scanout->ds);
>      }
>
> --
> 1.8.3.1
>
>
> --
Marc-André Lureau
Li Qiang Feb. 6, 2017, 3:16 a.m. UTC | #2
Hello Gerd,

Ping.

2017-01-23 17:09 GMT+08:00 Marc-André Lureau <marcandre.lureau@gmail.com>:

>
>
> On Sun, Jan 22, 2017 at 11:43 AM Li Qiang <liq3ea@gmail.com> wrote:
>
>> From: Li Qiang <liqiang6-s@360.cn>
>>
>> In virtio_gpu_set_scanout function, when creating the 'rect'
>> its refcount is set to 2, by pixman_image_create_bits and
>> qemu_create_displaysurface_pixman function. This can lead
>> a memory leak issues. This patch avoid this issue.
>>
>> Signed-off-by: Li Qiang <liqiang6-s@360.cn>
>>
>
>
> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
>
>
>
>> ---
>>  hw/display/virtio-gpu.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
>> index 7a15c61..4aecea3 100644
>> --- a/hw/display/virtio-gpu.c
>> +++ b/hw/display/virtio-gpu.c
>> @@ -608,6 +608,7 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g,
>>              cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
>>              return;
>>          }
>> +        pixman_image_unref(rect);
>>          dpy_gfx_replace_surface(g->scanout[ss.scanout_id].con,
>> scanout->ds);
>>      }
>>
>> --
>> 1.8.3.1
>>
>>
>> --
> Marc-André Lureau
>
Gerd Hoffmann Feb. 6, 2017, 2:30 p.m. UTC | #3
On Sa, 2017-01-21 at 23:42 -0800, Li Qiang wrote:
> From: Li Qiang <liqiang6-s@360.cn>
> 
> In virtio_gpu_set_scanout function, when creating the 'rect'
> its refcount is set to 2, by pixman_image_create_bits and
> qemu_create_displaysurface_pixman function. This can lead 
> a memory leak issues. This patch avoid this issue.
> 
> Signed-off-by: Li Qiang <liqiang6-s@360.cn>

Added to vga patch queue.

thanks,
  Gerd
diff mbox

Patch

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 7a15c61..4aecea3 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -608,6 +608,7 @@  static void virtio_gpu_set_scanout(VirtIOGPU *g,
             cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
             return;
         }
+        pixman_image_unref(rect);
         dpy_gfx_replace_surface(g->scanout[ss.scanout_id].con, scanout->ds);
     }