From patchwork Thu Jul 27 02:42:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 794180 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="H7zQcdq1"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xHxHm2Dzgz9s7F for ; Thu, 27 Jul 2017 12:48:36 +1000 (AEST) Received: from localhost ([::1]:40878 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daYqo-00020q-4V for incoming@patchwork.ozlabs.org; Wed, 26 Jul 2017 22:48:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54488) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1daYlG-0005Jg-1e for qemu-devel@nongnu.org; Wed, 26 Jul 2017 22:42:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1daYlF-0007lb-AG for qemu-devel@nongnu.org; Wed, 26 Jul 2017 22:42:50 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:38130) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1daYlF-0007lR-6R; Wed, 26 Jul 2017 22:42:49 -0400 Received: by mail-qt0-x243.google.com with SMTP id p3so8854706qtg.5; Wed, 26 Jul 2017 19:42:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tRS700DdLgCnDatCRcUUxY0ze33cvg1a1EXjrLyuMfk=; b=H7zQcdq16qO+QOADRLriRglbpsrEE2Fp78EdSccxGJl6x4vOI38OKVdjBYDnev2AVw Kij1/xp3+XyV6G3qoTLtLyU4KAUV6WmcGpytBI113NyHvtt3EoE5vVi4Ga3PmfaFk/Cd n7cYg+36SaI+Lza9drXOEcASM0T0f3ayC805HfEU1TggvySIsyCyO/9TpK+6nFcuOIoT g22KZEdFhHSBgKOqLzub23SethKxfEy+9+jDOLskMx4XT6hVUs7x5G9JTSFcxneOyY2R LDso2GZdFL5gF/2+8QdRkyIdzau9YmCYZFlNHwA7hzJVpOGgxKghDaG6ViZCAnsQ1clf Xg5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=tRS700DdLgCnDatCRcUUxY0ze33cvg1a1EXjrLyuMfk=; b=dq2uXbA7OMT8+HZjqE0O+4W0FvX+TonBXS0/JN0cGsgTr8+GmpKyNCXzwvaeeb7x7T aitEVMTQ5i1ydWe3lbbZjPICf5xcFilGu7IUEvZGOyjffAx7fZ96lKMSIxzfGTEAmflA HMfHFwaUNROiSe5giJ+ARcNuLw5FpNCm4jUaaoBIJATgFzYcCNDC230I4T+catMt0JyY qpnGoqCyHYaQCNyD8SEMdNlie7HBPuQLyMJUzVNyFIvdfpmMeUEjkI7pm5iuZM3XPTdN J2qgC7ZR6s9vGSf1H9wdO7jlpLzFYgziu8TaVFVK1ZOjd5C1cWnIu8KM2ZAcRNpF0O9d +U0g== X-Gm-Message-State: AIVw111uv/XDO+O3qUDBYZgU29mXgWFq7OjwwcSR3gnkjB+T5ITk0KoW PV6kBIiymcoEejbGLMoR1w== X-Received: by 10.237.62.177 with SMTP id n46mr3871652qtf.336.1501123368711; Wed, 26 Jul 2017 19:42:48 -0700 (PDT) Received: from yoga.offpageads.com ([138.117.48.223]) by smtp.gmail.com with ESMTPSA id g27sm13221147qtg.84.2017.07.26.19.42.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 26 Jul 2017 19:42:47 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Peter Maydell , =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= , Paolo Bonzini , Eric Blake Date: Wed, 26 Jul 2017 23:42:10 -0300 Message-Id: <20170727024224.22900-6-f4bug@amsat.org> X-Mailer: git-send-email 2.13.3 In-Reply-To: <20170727024224.22900-1-f4bug@amsat.org> References: <20170727024224.22900-1-f4bug@amsat.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PATCH for 2.10 v2 05/20] qcow2: fix null pointer dereference X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-trivial@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" It seems this assert() was somehow misplaced. block/qcow2-refcount.c:2193:42: warning: Array access (from variable 'on_disk_reftable') results in a null pointer dereference on_disk_reftable[refblock_index] = refblock_offset; ~~~~~~~~~~~~~~~~ ^ Reported-by: Clang Static Analyzer Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Eric Blake --- block/qcow2-refcount.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index c9b0dcb4f3..168fc32e7b 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -2189,6 +2189,8 @@ write_refblocks: * this will leak that range, but we can easily fix that by running * a leak-fixing check after this rebuild operation */ reftable_offset = -1; + } else { + assert(on_disk_reftable); } on_disk_reftable[refblock_index] = refblock_offset; @@ -2258,8 +2260,6 @@ write_refblocks: goto write_refblocks; } - assert(on_disk_reftable); - for (refblock_index = 0; refblock_index < reftable_size; refblock_index++) { cpu_to_be64s(&on_disk_reftable[refblock_index]); }