diff mbox

virtio-gpu: fix memory leak in virtio_gpu_resource_create_2d

Message ID 57df486e.8379240a.c3620.ff81@mx.google.com
State New
Headers show

Commit Message

Li Qiang Sept. 19, 2016, 2:07 a.m. UTC
From: Li Qiang <liqiang6-s@360.cn>

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>
---
 hw/display/virtio-gpu.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Marc-André Lureau Sept. 19, 2016, 7:47 a.m. UTC | #1
On Mon, Sep 19, 2016 at 6:08 AM Li Qiang <liq3ea@gmail.com> wrote:

> From: Li Qiang <liqiang6-s@360.cn>
>
> 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>

---
>  hw/display/virtio-gpu.c | 1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
> index 7fe6ed8..5b6d17b 100644
> --- a/hw/display/virtio-gpu.c
> +++ b/hw/display/virtio-gpu.c
> @@ -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;
>      }
> --
> 1.8.3.1
>
>
> --
Marc-André Lureau
Gerd Hoffmann Oct. 26, 2016, 12:52 p.m. UTC | #2
On So, 2016-09-18 at 19:07 -0700, Li Qiang wrote:
> From: Li Qiang <liqiang6-s@360.cn>
> 
> 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>

Added to vga queue.

thanks,
  Gerd
diff mbox

Patch

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 7fe6ed8..5b6d17b 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -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;
     }