From patchwork Wed Nov 9 21:59:50 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 124710 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 A37B71007DA for ; Thu, 10 Nov 2011 09:00:07 +1100 (EST) Received: from localhost ([::1]:58004 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROGBf-0003Se-MG for incoming@patchwork.ozlabs.org; Wed, 09 Nov 2011 17:00:03 -0500 Received: from eggs.gnu.org ([140.186.70.92]:50704) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROGBY-0003SV-RD for qemu-devel@nongnu.org; Wed, 09 Nov 2011 16:59:57 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ROGBX-0000Mv-OI for qemu-devel@nongnu.org; Wed, 09 Nov 2011 16:59:56 -0500 Received: from mnementh.archaic.org.uk ([81.2.115.146]:51067) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ROGBX-0000MS-0S for qemu-devel@nongnu.org; Wed, 09 Nov 2011 16:59:55 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.72) (envelope-from ) id 1ROGBS-0002k4-WF; Wed, 09 Nov 2011 21:59:50 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Wed, 9 Nov 2011 21:59:50 +0000 Message-Id: <1320875990-10517-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.2.5 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-Received-From: 81.2.115.146 Cc: Kevin Wolf , patches@linaro.org Subject: [Qemu-devel] [PATCH] hw/pc.c: Fix use-while-uninitialized of fd_type[] 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 Fix a use-while-uninitialized of the fd_type[] array (introduced in commit 34d4260e1, noticed by Coverity). This is more theoretical than practical, since it's quite hard to get here with floppy==NULL (the qdev_try_create() of the isa-fdc device has to fail). Signed-off-by: Peter Maydell --- hw/pc.c | 4 +--- 1 files changed, 1 insertions(+), 3 deletions(-) diff --git a/hw/pc.c b/hw/pc.c index 3015671..33778fe 100644 --- a/hw/pc.c +++ b/hw/pc.c @@ -335,7 +335,7 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, ISADevice *s) { int val, nb, nb_heads, max_track, last_sect, i; - FDriveType fd_type[2]; + FDriveType fd_type[2] = { FDRIVE_DRV_NONE, FDRIVE_DRV_NONE }; BlockDriverState *fd[MAX_FD]; static pc_cmos_init_late_arg arg; @@ -385,8 +385,6 @@ void pc_cmos_init(ram_addr_t ram_size, ram_addr_t above_4g_mem_size, bdrv_get_floppy_geometry_hint(fd[i], &nb_heads, &max_track, &last_sect, FDRIVE_DRV_NONE, &fd_type[i]); - } else { - fd_type[i] = FDRIVE_DRV_NONE; } } }