virtio-gpu: fix memory leak in virtio_gpu_resource_create_2d

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>
This commit is contained in:
Li Qiang 2016-09-18 19:07:11 -07:00 committed by Gerd Hoffmann
parent ede0cbeb78
commit cb3a0522b6

View File

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