From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wnrc7-00057H-0n for qemu-devel@nongnu.org; Fri, 23 May 2014 11:42:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Wnrby-00066i-Rv for qemu-devel@nongnu.org; Fri, 23 May 2014 11:42:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64896) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Wnrby-00066O-KT for qemu-devel@nongnu.org; Fri, 23 May 2014 11:42:22 -0400 From: Stefan Hajnoczi Date: Fri, 23 May 2014 17:41:35 +0200 Message-Id: <1400859725-31879-4-git-send-email-stefanha@redhat.com> In-Reply-To: <1400859725-31879-1-git-send-email-stefanha@redhat.com> References: <1400859725-31879-1-git-send-email-stefanha@redhat.com> Subject: [Qemu-devel] [PULL 03/33] qcow2: Fix memory leak in COW error path List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Peter Maydell , Stefan Hajnoczi From: Kevin Wolf This triggers if bs->drv becomes NULL in a concurrent request. This is currently only the case when corruption prevention kicks in (i.e. at most once per image, and after that it produces I/O errors). Signed-off-by: Kevin Wolf Signed-off-by: Stefan Hajnoczi --- block/qcow2-cluster.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 76d2bcf..4208dc0 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -379,7 +379,8 @@ static int coroutine_fn copy_sectors(BlockDriverState *bs, BLKDBG_EVENT(bs->file, BLKDBG_COW_READ); if (!bs->drv) { - return -ENOMEDIUM; + ret = -ENOMEDIUM; + goto out; } /* Call .bdrv_co_readv() directly instead of using the public block-layer -- 1.9.0