From ca58b45fbee05ef7ed938abc5308548866335937 Mon Sep 17 00:00:00 2001 From: Gerd Hoffmann Date: Fri, 1 Apr 2016 10:27:20 +0200 Subject: ui/virtio-gpu: add and use qemu_create_displaysurface_pixman Add a the new qemu_create_displaysurface_pixman function, to create a DisplaySurface backed by an existing pixman image. In that case there is no need to create a new pixman image pointing to the same backing storage. We can just use the existing image directly. This does not only simplify things a bit, but most importantly it gets the reference counting right, so the backing storage for the pixman image wouldn't be released underneath us. Use new function in virtio-gpu, where using it actually fixes use-after-free crashes. Cc: qemu-stable@nongnu.org Signed-off-by: Gerd Hoffmann Message-id: 1459499240-742-1-git-send-email-kraxel@redhat.com --- hw/display/virtio-gpu.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'hw/display') diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c index ddf3bfbef4..095d7ffa91 100644 --- a/hw/display/virtio-gpu.c +++ b/hw/display/virtio-gpu.c @@ -572,10 +572,7 @@ static void virtio_gpu_set_scanout(VirtIOGPU *g, scanout->width != ss.r.width || scanout->height != ss.r.height) { /* realloc the surface ptr */ - scanout->ds = qemu_create_displaysurface_from - (ss.r.width, ss.r.height, format, - pixman_image_get_stride(res->image), - (uint8_t *)pixman_image_get_data(res->image) + offset); + scanout->ds = qemu_create_displaysurface_pixman(res->image); if (!scanout->ds) { cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC; return; -- cgit v1.2.3