From patchwork Wed Apr 21 19:35:45 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 50674 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 0A2F4B7C33 for ; Thu, 22 Apr 2010 05:36:11 +1000 (EST) Received: from localhost ([127.0.0.1]:55643 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1O4fiS-0002OH-31 for incoming@patchwork.ozlabs.org; Wed, 21 Apr 2010 15:36:08 -0400 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 Received: from localhost.localdomain (sig-9-145-133-64.de.ibm.com [9.145.133.64]) by d12av02.megacenter.de.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id o3LJZAVj012058; Wed, 21 Apr 2010 21:35:10 +0200 From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Wed, 21 Apr 2010 20:35:45 +0100 Message-Id: <1271878545-5965-1-git-send-email-stefanha@linux.vnet.ibm.com> X-Mailer: git-send-email 1.7.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) Cc: Anthony Liguori , Stefan Hajnoczi , kvm@vger.kernel.org, Leszek Urbanski , Marcelo Tosatti , Avi Kivity , Aurelien Jarno Subject: [Qemu-devel] [PATCH][STABLE] block: Free iovec arrays allocated by multiwrite_merge() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 Acked-by: Kevin Wolf --- 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); }