From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:38661) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R37K8-000222-0K for qemu-devel@nongnu.org; Mon, 12 Sep 2011 10:17:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1R37K6-0007Bi-Py for qemu-devel@nongnu.org; Mon, 12 Sep 2011 10:17:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:64727) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R37K6-0007BS-Ip for qemu-devel@nongnu.org; Mon, 12 Sep 2011 10:17:22 -0400 From: Kevin Wolf Date: Mon, 12 Sep 2011 16:19:31 +0200 Message-Id: <1315837174-15327-33-git-send-email-kwolf@redhat.com> In-Reply-To: <1315837174-15327-1-git-send-email-kwolf@redhat.com> References: <1315837174-15327-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PATCH 32/35] qcow2: initialize metadata before inserting in cluster_allocs 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: 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 Signed-off-by: Kevin Wolf --- 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.6