From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:59155) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1cw3-0000Y4-VX for qemu-devel@nongnu.org; Thu, 08 Sep 2011 07:38:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R1cw2-0002k8-JY for qemu-devel@nongnu.org; Thu, 08 Sep 2011 07:38:23 -0400 Received: from mail-fx0-f45.google.com ([209.85.161.45]:62667) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1cw2-0002jv-62 for qemu-devel@nongnu.org; Thu, 08 Sep 2011 07:38:22 -0400 Received: by fxbb27 with SMTP id b27so1588618fxb.4 for ; Thu, 08 Sep 2011 04:38:20 -0700 (PDT) From: Frediano Ziglio Date: Thu, 8 Sep 2011 13:38:42 +0200 Message-Id: <1315481922-4690-1-git-send-email-freddy77@gmail.com> Subject: [Qemu-devel] [PATCH] qcow2: initialize metadata before inserting in cluster_allocs List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: kwolf@redhat.com Cc: qemu-devel@nongnu.org, Frediano Ziglio QCow2Meta structure was inserted into list before many fields are initialized. Currently is not a problem cause all occur in a lock but if qcow2_alloc_clusters would in a future unlock this lock some issues could arise. Initializing fields before inserting fix the problem. Signed-off-by: Frediano Ziglio --- block/qcow2-cluster.c | 10 +++++----- 1 files changed, 5 insertions(+), 5 deletions(-) diff --git a/block/qcow2-cluster.c b/block/qcow2-cluster.c index 113db8b..428b5ad 100644 --- a/block/qcow2-cluster.c +++ b/block/qcow2-cluster.c @@ -806,6 +806,11 @@ again: abort(); } + /* save info needed for meta data update */ + m->offset = offset; + m->n_start = n_start; + m->nb_clusters = nb_clusters; + QLIST_INSERT_HEAD(&s->cluster_allocs, m, next_in_flight); /* allocate a new cluster */ @@ -816,11 +821,6 @@ again: goto fail; } - /* save info needed for meta data update */ - m->offset = offset; - m->n_start = n_start; - m->nb_clusters = nb_clusters; - out: ret = qcow2_cache_put(bs, s->l2_table_cache, (void**) &l2_table); if (ret < 0) { -- 1.7.1