Received: from eggs.gnu.org ([2001:4830:134:3::10]:41956) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWrkE-000442-Ox for qemu-devel@nongnu.org; Mon, 08 Aug 2016 17:06:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bWrkC-00060U-Ob for qemu-devel@nongnu.org; Mon, 08 Aug 2016 17:05:57 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:43817) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bWrkC-0005zu-GN for qemu-devel@nongnu.org; Mon, 08 Aug 2016 17:05:56 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u78KxpvL100323 for ; Mon, 8 Aug 2016 17:05:56 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 24na7fuqdm-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 08 Aug 2016 17:05:55 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 8 Aug 2016 15:05:55 -0600 From: Michael Roth Date: Mon, 8 Aug 2016 16:04:04 -0500 In-Reply-To: <1470690267-31454-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1470690267-31454-1-git-send-email-mdroth@linux.vnet.ibm.com> Message-Id: <1470690267-31454-34-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 33/56] backup: Don't leak BackupBlockJob in error path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, Kevin Wolf From: Kevin Wolf Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz Reviewed-by: Alberto Garcia (cherry picked from commit 91ab68837933232bcef99da7c968e6d41900419b) Signed-off-by: Michael Roth --- block/backup.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block/backup.c b/block/backup.c index 491fd14..370c285 100644 --- a/block/backup.c +++ b/block/backup.c @@ -504,6 +504,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target, { int64_t len; BlockDriverInfo bdi; + BackupBlockJob *job = NULL; int ret; assert(bs); @@ -568,8 +569,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target, goto error; } - BackupBlockJob *job = block_job_create(&backup_job_driver, bs, speed, - cb, opaque, errp); + job = block_job_create(&backup_job_driver, bs, speed, cb, opaque, errp); if (!job) { goto error; } @@ -610,4 +610,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target, if (sync_bitmap) { bdrv_reclaim_dirty_bitmap(bs, sync_bitmap, NULL); } + if (job) { + block_job_unref(&job->common); + } } -- 1.9.1