From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35879) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCQ2f-0003mc-TH for qemu-devel@nongnu.org; Sun, 09 Feb 2014 03:47:16 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WCQ2Z-0001B2-Sd for qemu-devel@nongnu.org; Sun, 09 Feb 2014 03:47:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:62163) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WCQ2Z-0001Av-Kd for qemu-devel@nongnu.org; Sun, 09 Feb 2014 03:47:03 -0500 From: Kevin Wolf Date: Sun, 9 Feb 2014 09:46:29 +0100 Message-Id: <1391935590-12264-18-git-send-email-kwolf@redhat.com> In-Reply-To: <1391935590-12264-1-git-send-email-kwolf@redhat.com> References: <1391935590-12264-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 17/18] blkdebug: Don't leak bs->file on failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org Reported-by: Laszlo Ersek Signed-off-by: Kevin Wolf Reviewed-by: Laszlo Ersek --- block/blkdebug.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index 56c4cd0..8eb0db0 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -396,14 +396,14 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, if (error_is_set(&local_err)) { error_propagate(errp, local_err); ret = -EINVAL; - goto fail; + goto out; } /* Read rules from config file or command line options */ config = qemu_opt_get(opts, "config"); ret = read_config(s, config, options, errp); if (ret) { - goto fail; + goto out; } /* Set initial state */ @@ -414,7 +414,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, flags, true, false, &local_err); if (ret < 0) { error_propagate(errp, local_err); - goto fail; + goto out; } /* Set request alignment */ @@ -424,11 +424,15 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, } else { error_setg(errp, "Invalid alignment"); ret = -EINVAL; - goto fail; + goto fail_unref; } ret = 0; -fail: + goto out; + +fail_unref: + bdrv_unref(bs->file); +out: qemu_opts_del(opts); return ret; } -- 1.8.1.4