From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39686) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WC3gR-0003tD-3x for qemu-devel@nongnu.org; Sat, 08 Feb 2014 03:54:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WC3gL-0002je-3v for qemu-devel@nongnu.org; Sat, 08 Feb 2014 03:54:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44086) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WC3gK-0002jX-ST for qemu-devel@nongnu.org; Sat, 08 Feb 2014 03:54:37 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s188sYvf026313 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Sat, 8 Feb 2014 03:54:35 -0500 From: Kevin Wolf Date: Sat, 8 Feb 2014 09:54:30 +0100 Message-Id: <1391849670-10352-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH] blkdebug: Don't leak bs->file on failure List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: kwolf@redhat.com, lersek@redhat.com, stefanha@redhat.com Signed-off-by: Kevin Wolf --- block/blkdebug.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index 56c4cd0..519b483 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -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 fail_unref; } /* Set request alignment */ @@ -424,10 +424,13 @@ 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; + return 0; + +fail_unref: + bdrv_unref(bs->file); fail: qemu_opts_del(opts); return ret; -- 1.8.1.4