qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Li Qiang <liq3ea@gmail.com>
To: kraxel@redhat.com, marcandre.lureau@redhat.com, qemu-devel@nongnu.org
Cc: liqiang6-s@360.cn, Li Qiang <liq3ea@gmail.com>
Subject: [Qemu-devel] [PATCH] virtio-gpu: fix memory leak in resource attach backing
Date: Thu, 29 Dec 2016 04:28:41 -0500	[thread overview]
Message-ID: <1483003721-65360-1-git-send-email-liq3ea@gmail.com> (raw)

In the resource attach backing function, everytime it will
allocate 'res->iov' thus can leading a memory leak. This
patch avoid this.

Signed-off-by: Li Qiang <liq3ea@gmail.com>
---
 hw/display/virtio-gpu.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/hw/display/virtio-gpu.c b/hw/display/virtio-gpu.c
index 5f32e1a..045f296 100644
--- a/hw/display/virtio-gpu.c
+++ b/hw/display/virtio-gpu.c
@@ -705,6 +705,11 @@ virtio_gpu_resource_attach_backing(VirtIOGPU *g,
         return;
     }
 
+    if (res->iov) {
+        cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
+        return;
+    }
+
     ret = virtio_gpu_create_mapping_iov(&ab, cmd, &res->addrs, &res->iov);
     if (ret != 0) {
         cmd->error = VIRTIO_GPU_RESP_ERR_UNSPEC;
-- 
1.8.3.1

             reply	other threads:[~2016-12-29  9:28 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-29  9:28 Li Qiang [this message]
2016-12-29 14:57 ` [Qemu-devel] [PATCH] virtio-gpu: fix memory leak in resource attach backing Marc-André Lureau
2016-12-30  6:13   ` Li Qiang
2017-01-03  9:41   ` Gerd Hoffmann

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=1483003721-65360-1-git-send-email-liq3ea@gmail.com \
    --to=liq3ea@gmail.com \
    --cc=kraxel@redhat.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).