qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qcow2: initialize metadata before inserting in cluster_allocs
@ 2011-09-08 11:38 Frediano Ziglio
  2011-09-08 12:11 ` Kevin Wolf
  0 siblings, 1 reply; 2+ messages in thread
From: Frediano Ziglio @ 2011-09-08 11:38 UTC (permalink / raw)
  To: kwolf; +Cc: qemu-devel, 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 <freddy77@gmail.com>
---
 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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] qcow2: initialize metadata before inserting in cluster_allocs
  2011-09-08 11:38 [Qemu-devel] [PATCH] qcow2: initialize metadata before inserting in cluster_allocs Frediano Ziglio
@ 2011-09-08 12:11 ` Kevin Wolf
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Wolf @ 2011-09-08 12:11 UTC (permalink / raw)
  To: Frediano Ziglio; +Cc: qemu-devel

Am 08.09.2011 13:38, schrieb 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 <freddy77@gmail.com>

Thanks, applied to the block branch.

Kevin

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-09-08 12:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-08 11:38 [Qemu-devel] [PATCH] qcow2: initialize metadata before inserting in cluster_allocs Frediano Ziglio
2011-09-08 12:11 ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).