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: 5009 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id 6A37923E01 for ; Wed, 9 Nov 2011 22:28:15 +0000 (UTC) Received: from mail-fx0-f52.google.com (mail-fx0-f52.google.com [209.85.161.52]) by fiordland.canonical.com (Postfix) with ESMTP id 54E25A188BD for ; Wed, 9 Nov 2011 22:28:15 +0000 (UTC) Received: by faan26 with SMTP id n26so3111234faa.11 for ; Wed, 09 Nov 2011 14:28:15 -0800 (PST) Received: by 10.152.102.138 with SMTP id fo10mr2898458lab.44.1320877695114; Wed, 09 Nov 2011 14:28:15 -0800 (PST) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.152.3.196 with SMTP id e4cs768lae; Wed, 9 Nov 2011 14:28:14 -0800 (PST) Received: by 10.180.100.34 with SMTP id ev2mr4967694wib.41.1320875994369; Wed, 09 Nov 2011 13:59:54 -0800 (PST) Received: from mnementh.archaic.org.uk (mnementh.archaic.org.uk. [81.2.115.146]) by mx.google.com with ESMTPS id fw12si1665609wbb.129.2011.11.09.13.59.53 (version=TLSv1/SSLv3 cipher=OTHER); Wed, 09 Nov 2011 13:59:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) client-ip=81.2.115.146; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 81.2.115.146 as permitted sender) smtp.mail=pm215@archaic.org.uk 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 Cc: patches@linaro.org, Kevin Wolf Subject: [PATCH] hw/pc.c: Fix use-while-uninitialized of fd_type[] 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 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; } } }