From patchwork Mon Jul 31 10:21:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 795675 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=) 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 3xLb9h4YJDz9sRg for ; Mon, 31 Jul 2017 20:22:32 +1000 (AEST) Received: from localhost ([::1]:58550 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dc7qH-00047q-Rx for incoming@patchwork.ozlabs.org; Mon, 31 Jul 2017 06:22:29 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50904) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dc7pd-00046r-VI for qemu-devel@nongnu.org; Mon, 31 Jul 2017 06:21:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dc7pb-00069L-B2 for qemu-devel@nongnu.org; Mon, 31 Jul 2017 06:21:49 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:32833) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dc7pb-00068X-30; Mon, 31 Jul 2017 06:21:47 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 341EF42ABF; Mon, 31 Jul 2017 13:21:46 +0300 (MSK) Received: from tls.msk.ru (mjt.vpn.tls.msk.ru [192.168.177.99]) by tsrv.corpit.ru (Postfix) with SMTP id 2691BB78; Mon, 31 Jul 2017 13:21:44 +0300 (MSK) Received: (nullmailer pid 5558 invoked by uid 1000); Mon, 31 Jul 2017 10:21:45 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Date: Mon, 31 Jul 2017 13:21:29 +0300 Message-Id: X-Mailer: git-send-email 2.11.0 In-Reply-To: References: In-Reply-To: References: MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 86.62.121.231 Subject: [Qemu-devel] [PULL 10/25] 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, Michael Tokarev , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé 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 Signed-off-by: Michael Tokarev --- 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]); }