qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/pc.c: Fix use-while-uninitialized of fd_type[]
@ 2011-11-09 21:59 Peter Maydell
  2011-11-10 13:04 ` Kevin Wolf
  0 siblings, 1 reply; 2+ messages in thread
From: Peter Maydell @ 2011-11-09 21:59 UTC (permalink / raw)
  To: qemu-devel; +Cc: Kevin Wolf, patches

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 <peter.maydell@linaro.org>
---
 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;
             }
         }
     }
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/pc.c: Fix use-while-uninitialized of fd_type[]
  2011-11-09 21:59 [Qemu-devel] [PATCH] hw/pc.c: Fix use-while-uninitialized of fd_type[] Peter Maydell
@ 2011-11-10 13:04 ` Kevin Wolf
  0 siblings, 0 replies; 2+ messages in thread
From: Kevin Wolf @ 2011-11-10 13:04 UTC (permalink / raw)
  To: Peter Maydell; +Cc: qemu-devel, patches

Am 09.11.2011 22:59, schrieb Peter Maydell:
> 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 <peter.maydell@linaro.org>

Thanks, applied to the block-stable branch (for 1.0)

Kevin

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2011-11-10 13:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-09 21:59 [Qemu-devel] [PATCH] hw/pc.c: Fix use-while-uninitialized of fd_type[] Peter Maydell
2011-11-10 13:04 ` Kevin Wolf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).