From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55206) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPa9Y-00077d-OR for qemu-devel@nongnu.org; Fri, 27 Sep 2013 11:40:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VPa9S-0007sb-Km for qemu-devel@nongnu.org; Fri, 27 Sep 2013 11:40:24 -0400 Received: from mx1.redhat.com ([209.132.183.28]:56852) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPa9S-0007sS-E8 for qemu-devel@nongnu.org; Fri, 27 Sep 2013 11:40:18 -0400 From: Kevin Wolf Date: Fri, 27 Sep 2013 17:39:26 +0200 Message-Id: <1380296370-14523-27-git-send-email-kwolf@redhat.com> In-Reply-To: <1380296370-14523-1-git-send-email-kwolf@redhat.com> References: <1380296370-14523-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 26/30] qcow2: Always use error path in l2_allocate List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Max Reitz Just returning -errno in some cases prevents trace_qcow2_l2_allocate_done from being executed (and, in one case, also the unused allocated L2 table from being freed). Always going down the error path fixes this. Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/qcow2-cluster.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 153ea50..c743db1 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -200,7 +200,8 @@ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table) l2_offset = qcow2_alloc_clusters(bs, s->l2_size * sizeof(uint64_t)); if (l2_offset < 0) { - return l2_offset; + ret = l2_offset; + goto fail; } ret = qcow2_cache_flush(bs, s->refcount_block_cache); @@ -213,7 +214,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table) trace_qcow2_l2_allocate_get_empty(bs, l1_index); ret = qcow2_cache_get_empty(bs, s->l2_table_cache, l2_offset, (void**) table); if (ret < 0) { - return ret; + goto fail; } l2_table = *table; -- 1.8.1.4