Blob Blame History Raw
From 8dddbd7dc9948e743695166bab2b7ca94012badf Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Fri, 7 Feb 2014 15:29:00 +0100
Subject: [PATCH 25/37] lock: Fix memory leaks in bdrv_co_do_pwritev()

Message-id: <1392117622-28812-26-git-send-email-kwolf@redhat.com>
Patchwork-id: 57190
O-Subject: [RHEL-7.0 qemu-kvm PATCH v2 25/37] block: Fix memory leaks in bdrv_co_do_pwritev()
Bugzilla: 748906
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
RH-Acked-by: Max Reitz <mreitz@redhat.com>

The error path for a failure in one of the two bdrv_aligned_preadv()
calls leaked head_buf or tail_buf, respectively. This fixes the memory
leak.

Reported-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
---
 block.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/block.c b/block.c
index 3ec3949..9eeb072 100644
--- a/block.c
+++ b/block.c
@@ -3180,9 +3180,9 @@ fail:
 
     if (use_local_qiov) {
         qemu_iovec_destroy(&local_qiov);
-        qemu_vfree(head_buf);
-        qemu_vfree(tail_buf);
     }
+    qemu_vfree(head_buf);
+    qemu_vfree(tail_buf);
 
     return ret;
 }
-- 
1.7.1