From: Kevin Wolf Date: Thu, 14 Apr 2016 10:59:55 +0000 (+0200) Subject: backup: Don't leak BackupBlockJob in error path X-Git-Tag: TizenStudio_2.0_p4.0~6^2~12^2~6^2~248^2~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=91ab68837933232bcef99da7c968e6d41900419b;p=sdk%2Femulator%2Fqemu.git backup: Don't leak BackupBlockJob in error path Signed-off-by: Kevin Wolf Reviewed-by: Max Reitz Reviewed-by: Alberto Garcia --- 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); + } }