qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Marc-André Lureau" <mlureau@redhat.com>
To: Li Qiang <liq3ea@gmail.com>
Cc: kraxel@redhat.com, marcandre lureau <marcandre.lureau@redhat.com>,
	qemu-devel@nongnu.org, liqiang6-s@360.cn
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)	[thread overview]
Message-ID: <2074312993.7518572.1483019800774.JavaMail.zimbra@redhat.com> (raw)
In-Reply-To: <1482999086-59795-1-git-send-email-liq3ea@gmail.com>

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 <liq3ea@gmail.com>

Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>

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	other threads:[~2016-12-29 13:57 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-29  8:11 [Qemu-devel] [PATCH] virtio-gpu-3d: fix memory leak in resource attach backing Li Qiang
2016-12-29 13:56 ` Marc-André Lureau [this message]
2016-12-30  1:11   ` Li Qiang

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2074312993.7518572.1483019800774.JavaMail.zimbra@redhat.com \
    --to=mlureau@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=liq3ea@gmail.com \
    --cc=liqiang6-s@360.cn \
    --cc=marcandre.lureau@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).