virtio-gpu: fix memory leak in set scanout
authorLi Qiang <liqiang6-s@360.cn>
Sun, 22 Jan 2017 07:42:33 +0000 (23:42 -0800)
committerGerd Hoffmann <kraxel@redhat.com>
Fri, 10 Feb 2017 15:49:45 +0000 (16:49 +0100)
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>
Message-id: 5884626f.5b2f6b0a.1bfff.3037@mx.google.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/display/virtio-gpu.c

index 444ca064c137bba4c75c44e7e09c16c9e71ee19a..9b530ab5b02bad87b74529b9bed4120d121a1fd4 100644 (file)
@@ -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);
     }