From patchwork Wed May 4 09:39:19 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kevin Wolf X-Patchwork-Id: 618331 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3r0Clk10vBz9t44 for ; Wed, 4 May 2016 19:43:30 +1000 (AEST) Received: from localhost ([::1]:46646 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axtL1-0002ki-LW for incoming@patchwork.ozlabs.org; Wed, 04 May 2016 05:43:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axtII-0005h1-Ui for qemu-devel@nongnu.org; Wed, 04 May 2016 05:40:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1axtI7-0005s6-9N for qemu-devel@nongnu.org; Wed, 04 May 2016 05:40:29 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33930) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1axtHp-0005ag-80; Wed, 04 May 2016 05:40:05 -0400 Received: from int-mx14.intmail.prod.int.phx2.redhat.com (int-mx14.intmail.prod.int.phx2.redhat.com [10.5.11.27]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B3A1E63157; Wed, 4 May 2016 09:39:48 +0000 (UTC) Received: from noname.str.redhat.com. (dhcp-192-197.str.redhat.com [10.33.192.197]) by int-mx14.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id u449dYe6000875; Wed, 4 May 2016 05:39:47 -0400 From: Kevin Wolf To: qemu-block@nongnu.org Date: Wed, 4 May 2016 11:39:19 +0200 Message-Id: <1462354765-14037-9-git-send-email-kwolf@redhat.com> In-Reply-To: <1462354765-14037-1-git-send-email-kwolf@redhat.com> References: <1462354765-14037-1-git-send-email-kwolf@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.27 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 04 May 2016 09:39:48 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH 08/14] backup: Don't leak BackupBlockJob in error path X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kwolf@redhat.com, berto@igalia.com, jcody@redhat.com, qemu-devel@nongnu.org, mreitz@redhat.com, jsnow@redhat.com Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Kevin Wolf Reviewed-by: Alberto Garcia Reviewed-by: Max Reitz --- block/backup.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/block/backup.c b/block/backup.c index fec45e8..a990cf1 100644 --- a/block/backup.c +++ b/block/backup.c @@ -485,6 +485,7 @@ void backup_start(BlockDriverState *bs, BlockDriverState *target, { int64_t len; BlockDriverInfo bdi; + BackupBlockJob *job = NULL; int ret; assert(bs); @@ -542,8 +543,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; } @@ -584,4 +584,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); + } }