From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1O4fhh-0002Lk-VI for qemu-devel@nongnu.org; Wed, 21 Apr 2010 15:35:22 -0400 Received: from [140.186.70.92] (port=50561 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4fhf-0002Eb-32 for qemu-devel@nongnu.org; Wed, 21 Apr 2010 15:35:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1O4fha-0002Er-DJ for qemu-devel@nongnu.org; Wed, 21 Apr 2010 15:35:18 -0400 Received: from mtagate2.de.ibm.com ([195.212.17.162]:55271) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1O4fha-0002EQ-5K for qemu-devel@nongnu.org; Wed, 21 Apr 2010 15:35:14 -0400 Received: from d12nrmr1607.megacenter.de.ibm.com (d12nrmr1607.megacenter.de.ibm.com [9.149.167.49]) by mtagate2.de.ibm.com (8.13.1/8.13.1) with ESMTP id o3LJZBR0005524 for ; Wed, 21 Apr 2010 19:35:11 GMT Received: from d12av02.megacenter.de.ibm.com (d12av02.megacenter.de.ibm.com [9.149.165.228]) by d12nrmr1607.megacenter.de.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id o3LJZBPq1302570 for ; Wed, 21 Apr 2010 21:35:11 +0200 Received: from d12av02.megacenter.de.ibm.com (loopback [127.0.0.1]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id o3LJZAs6012346 for ; Wed, 21 Apr 2010 21:35:11 +0200 From: Stefan Hajnoczi Date: Wed, 21 Apr 2010 20:35:45 +0100 Message-Id: <1271878545-5965-1-git-send-email-stefanha@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH][STABLE] block: Free iovec arrays allocated by multiwrite_merge() List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Anthony Liguori , Stefan Hajnoczi , kvm@vger.kernel.org, Leszek Urbanski , Marcelo Tosatti , Avi Kivity , Aurelien Jarno A new iovec array is allocated when creating a merged write request. This patch ensures that the iovec array is deleted in addition to its qiov owner. Reported-by: Leszek Urbanski Signed-off-by: Stefan Hajnoczi --- This fixes the virtio-blk memory leak that has recently been reported by Leszek Urbanski . The patch should apply to qemu.git and qemu-kvm.git. I'm proposing this patch for both qemu and qemu-kvm and their stable branches. Sorry if the CCs are overkill, please let me know so I can follow the process better next time. block.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-) diff --git a/block.c b/block.c index 0881c93..99dd0f3 100644 --- a/block.c +++ b/block.c @@ -1731,6 +1731,9 @@ static void multiwrite_user_cb(MultiwriteCB *mcb) for (i = 0; i < mcb->num_callbacks; i++) { mcb->callbacks[i].cb(mcb->callbacks[i].opaque, mcb->error); + if (mcb->callbacks[i].free_qiov) { + qemu_iovec_destroy(mcb->callbacks[i].free_qiov); + } qemu_free(mcb->callbacks[i].free_qiov); qemu_vfree(mcb->callbacks[i].free_buf); } -- 1.7.0