summaryrefslogtreecommitdiff
path: root/hw
diff options
context:
space:
mode:
authorLi Qiang <liq3ea@gmail.com>2016-12-29 03:11:26 -0500
committerGerd Hoffmann <kraxel@redhat.com>2017-01-03 15:47:21 +0100
commit33243031dad02d161225ba99d782616da133f689 (patch)
treead918b494795301504981bf77aaa1fb5379bcd2a /hw
parentb8e23926c568f2e963af39028b71c472e3023793 (diff)
downloadqemu-33243031dad02d161225ba99d782616da133f689.zip
virtio-gpu-3d: fix memory leak in resource attach backing
If the virgl_renderer_resource_attach_iov function fails the 'res_iovs' will be leaked. Add check of the return value to free the 'res_iovs' when failing. Signed-off-by: Li Qiang <liq3ea@gmail.com> Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com> Message-id: 1482999086-59795-1-git-send-email-liq3ea@gmail.com Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Diffstat (limited to 'hw')
-rw-r--r--hw/display/virtio-gpu-3d.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c
index e29f099bd5..b13ced38fa 100644
--- a/hw/display/virtio-gpu-3d.c
+++ b/hw/display/virtio-gpu-3d.c
@@ -291,8 +291,11 @@ static void virgl_resource_attach_backing(VirtIOGPU *g,
return;
}
- virgl_renderer_resource_attach_iov(att_rb.resource_id,
- res_iovs, att_rb.nr_entries);
+ ret = virgl_renderer_resource_attach_iov(att_rb.resource_id,
+ res_iovs, att_rb.nr_entries);
+
+ if (ret != 0)
+ virtio_gpu_cleanup_mapping_iov(res_iovs, att_rb.nr_entries);
}
static void virgl_resource_detach_backing(VirtIOGPU *g,