qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] virtio-gpu-3d: fix memory leak in resource atta


From: Marc-André Lureau
Subject: Re: [Qemu-devel] [PATCH] virtio-gpu-3d: fix memory leak in resource attach backing
Date: Thu, 29 Dec 2016 08:56:40 -0500 (EST)

Hi

----- Original Message -----
> 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 <address@hidden>

Reviewed-by: Marc-André Lureau <address@hidden>

Interestingly, in vrend_renderer_resource_attach_iov(), if the resource has 
already been attached, it returns 0 too, which will also leak. I guess the fix 
is it return an error in this case.


> ---
>  hw/display/virtio-gpu-3d.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/display/virtio-gpu-3d.c b/hw/display/virtio-gpu-3d.c
> index 23f39de..07b3691 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,
> --
> 1.8.3.1
> 
> 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]