[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PULL 17/20] vt82c686: fix coverity warning about out-of-
From: |
Michael Tokarev |
Subject: |
[Qemu-trivial] [PULL 17/20] vt82c686: fix coverity warning about out-of-bounds write |
Date: |
Thu, 11 Dec 2014 21:16:05 +0300 |
From: zhanghailiang <address@hidden>
Refactor superio_ioport_writeb to fix the out of bounds write warning.
In addition, fix two typos: s/chage/change/
Signed-off-by: zhanghailiang <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
hw/isa/vt82c686.c | 41 +++++++++++++++++++----------------------
1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c
index e0c235c..223b947 100644
--- a/hw/isa/vt82c686.c
+++ b/hw/isa/vt82c686.c
@@ -50,13 +50,13 @@ typedef struct VT82C686BState {
static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data,
unsigned size)
{
- int can_write;
SuperIOConfig *superio_conf = opaque;
DPRINTF("superio_ioport_writeb address 0x%x val 0x%x\n", addr, data);
if (addr == 0x3f0) {
superio_conf->index = data & 0xff;
} else {
+ bool can_write = true;
/* 0x3f1 */
switch (superio_conf->index) {
case 0x00 ... 0xdf:
@@ -68,30 +68,27 @@ static void superio_ioport_writeb(void *opaque, hwaddr
addr, uint64_t data,
case 0xf7:
case 0xf9 ... 0xfb:
case 0xfd ... 0xff:
- can_write = 0;
+ can_write = false;
break;
- default:
- can_write = 1;
-
- if (can_write) {
- switch (superio_conf->index) {
- case 0xe7:
- if ((data & 0xff) != 0xfe) {
- DPRINTF("chage uart 1 base. unsupported yet\n");
- }
- break;
- case 0xe8:
- if ((data & 0xff) != 0xbe) {
- DPRINTF("chage uart 2 base. unsupported yet\n");
- }
- break;
-
- default:
- superio_conf->config[superio_conf->index] = data & 0xff;
- }
+ case 0xe7:
+ if ((data & 0xff) != 0xfe) {
+ DPRINTF("change uart 1 base. unsupported yet\n");
+ can_write = false;
+ }
+ break;
+ case 0xe8:
+ if ((data & 0xff) != 0xbe) {
+ DPRINTF("change uart 2 base. unsupported yet\n");
+ can_write = false;
}
+ break;
+ default:
+ break;
+
+ }
+ if (can_write) {
+ superio_conf->config[superio_conf->index] = data & 0xff;
}
- superio_conf->config[superio_conf->index] = data & 0xff;
}
}
--
2.1.3
- [Qemu-trivial] [PULL 07/20] Drop superfluous conditionals around qemu_opts_del(), (continued)
- [Qemu-trivial] [PULL 07/20] Drop superfluous conditionals around qemu_opts_del(), Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 14/20] fw_cfg: remove superfluous blank line, Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 01/20] qmp: fix typo in input-send-event examples, Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 19/20] hpet: increase spelling precision, Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 13/20] get_maintainer.pl: Remove the --git-chief-penguins option, Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 11/20] util: Use g_new() & friends where that makes obvious sense, Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 18/20] pflash_cfi02.c: associate "cfi.pflash02" to "Storage devices" category, Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 16/20] virtio: remove useless declaration of virtio_net_init(), Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 10/20] util: Fuse g_malloc(); memset() into g_new0(), Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 12/20] configure: Replace which(1) with "has", Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 17/20] vt82c686: fix coverity warning about out-of-bounds write,
Michael Tokarev <=
- [Qemu-trivial] [PULL 08/20] Drop superfluous conditionals around g_strdup(), Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 09/20] util: Drop superfluous conditionals around g_free(), Michael Tokarev, 2014/12/11
- [Qemu-trivial] [PULL 20/20] Sort include/qemu/typedefs.h, Michael Tokarev, 2014/12/11
- Re: [Qemu-trivial] [Qemu-devel] [PULL 00/20] Trivial patches for 2014-12-11, Peter Maydell, 2014/12/11