virtio-gpu: fix memory leak in virtio_gpu_resource_create_2d
authorLi Qiang <liqiang6-s@360.cn>
Mon, 19 Sep 2016 02:07:11 +0000 (19:07 -0700)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 26 Oct 2016 12:52:21 +0000 (14:52 +0200)
In virtio gpu resource create dispatch, if the pixman format is zero
it doesn't free the resource object allocated previously. Thus leading
a host memory leak issue. This patch avoid this.

Signed-off-by: Li Qiang <liqiang6-s@360.cn>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-id: 57df486e.8379240a.c3620.ff81@mx.google.com
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
hw/display/virtio-gpu.c

index fa6fd0e53f2ea7bf34d9101bf0f8cdfba8ef25d1..60bce94d6b4a7ee5aabcd019f993a328119760de 100644 (file)
@@ -333,6 +333,7 @@ static void virtio_gpu_resource_create_2d(VirtIOGPU *g,
         qemu_log_mask(LOG_GUEST_ERROR,
                       "%s: host couldn't handle guest format %d\n",
                       __func__, c2d.format);
+        g_free(res);
         cmd->error = VIRTIO_GPU_RESP_ERR_INVALID_PARAMETER;
         return;
     }