From patchwork Thu Sep 8 11:38:42 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frediano Ziglio X-Patchwork-Id: 113891 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id C68E0B6F7F for ; Thu, 8 Sep 2011 21:38:32 +1000 (EST) Received: from localhost ([::1]:57637 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1R1cw9-0000ZM-V1 for incoming@patchwork.ozlabs.org; Thu, 08 Sep 2011 07:38:29 -0400 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) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; bh=qYP9uhsB5gSma+hVMbpTDYisL5nUyxmYftTWZTEV28c=; b=x7L5mFUhHvFOIWyRkmt3ElQQCiGSICibH7ARlOHfqtMw9+EhClGAbT8v6KN6llXRqs /nRbKQiEYCM9G3PDDOss/8XSChsToSEpRox5/of2jLoIRhseNwex3x/Bn7zCtXOAMRJk 2uSC3kEmYEfwS862f5WPovDhCs+SUDX5BA1KE= Received: by 10.223.97.136 with SMTP id l8mr979347fan.101.1315481900767; Thu, 08 Sep 2011 04:38:20 -0700 (PDT) Received: from obol602.omnitel.it (82-149-225-171.static.aixit.com [82.149.225.171]) by mx.google.com with ESMTPS id a17sm1253617faf.22.2011.09.08.04.38.14 (version=SSLv3 cipher=OTHER); Thu, 08 Sep 2011 04:38:19 -0700 (PDT) From: Frediano Ziglio To: kwolf@redhat.com Date: Thu, 8 Sep 2011 13:38:42 +0200 Message-Id: <1315481922-4690-1-git-send-email-freddy77@gmail.com> X-Mailer: git-send-email 1.7.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 209.85.161.45 Cc: qemu-devel@nongnu.org, Frediano Ziglio Subject: [Qemu-devel] [PATCH] qcow2: initialize metadata before inserting in cluster_allocs X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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) {