From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55795) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPaBI-0001b6-Gm for qemu-devel@nongnu.org; Fri, 27 Sep 2013 11:42:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VPaBB-0000BT-0k for qemu-devel@nongnu.org; Fri, 27 Sep 2013 11:42:12 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34020) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPaBA-0000BO-Pz for qemu-devel@nongnu.org; Fri, 27 Sep 2013 11:42:04 -0400 From: Kevin Wolf Date: Fri, 27 Sep 2013 17:39:25 +0200 Message-Id: <1380296370-14523-26-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 25/30] qcow2: Don't put invalid L2 table into cache 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 In l2_allocate, the fail path is executed if qcow2_cache_flush fails. However, the L2 table has not yet been fetched from the L2 table cache. The qcow2_cache_put in the fail path therefore basically gives an undefined argument as the L2 table address (in this case). Signed-off-by: Max Reitz Signed-off-by: Kevin Wolf --- block/qcow2-cluster.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index ffa8941..153ea50 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -188,7 +188,7 @@ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table) { BDRVQcowState *s = bs->opaque; uint64_t old_l2_offset; - uint64_t *l2_table; + uint64_t *l2_table = NULL; int64_t l2_offset; int ret; @@ -265,7 +265,9 @@ static int l2_allocate(BlockDriverState *bs, int l1_index, uint64_t **table) fail: trace_qcow2_l2_allocate_done(bs, l1_index, ret); - qcow2_cache_put(bs, s->l2_table_cache, (void**) table); + if (l2_table != NULL) { + qcow2_cache_put(bs, s->l2_table_cache, (void**) table); + } s->l1_table[l1_index] = old_l2_offset; return ret; } -- 1.8.1.4