Patchwork [5/8] win32-aio: Fix memory leak

login
register
mail settings
Submitter Stefan Hajnoczi
Date Jan. 18, 2013, 4:28 p.m.
Message ID <1358526521-24300-6-git-send-email-stefanha@redhat.com>
Download mbox | patch
Permalink /patch/213677/
State New
Headers show

Comments

Stefan Hajnoczi - Jan. 18, 2013, 4:28 p.m.
From: Kevin Wolf <kwolf@redhat.com>

The buffer is allocated for both reads and writes, and obviously it
should be freed even if an error occurs.

Cc: qemu-stable@nongnu.org
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
 block/win32-aio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch

diff --git a/block/win32-aio.c b/block/win32-aio.c
index e4b7b75..b9236ea 100644
--- a/block/win32-aio.c
+++ b/block/win32-aio.c
@@ -87,8 +87,8 @@  static void win32_aio_process_completion(QEMUWin32AIOState *s,
                 memcpy(qiov->iov[i].iov_base, p, qiov->iov[i].iov_len);
                 p += qiov->iov[i].iov_len;
             }
-            qemu_vfree(waiocb->buf);
         }
+        qemu_vfree(waiocb->buf);
     }