Skip to contentSkip to conversation

qcow2: initialize metadata before inserting in cluster_allocs

PATCH Applied Frediano Ziglio 2 participants 2 messages Sep 8, 2011 Block layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 qcow2: initialize metadata before inserting in cluster_allocs

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.

---
 block/qcow2-cluster.c |   10 +++++-----
 1 files changed, 5 insertions(+), 5 deletions(-)
block/qcow2-cluster.c +5 -5
index 113db8b..428b5ad 100644
@@ -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) {
Signature · 1 line
1.7.1
Applied
#1 lore raw

Am 08.09.2011 13:38, schrieb Frediano Ziglio:

Quoted 7 lines

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.

Thanks, applied to the block branch.

Kevin