* [Qemu-devel] [PATCH] hw/mips_itu: fix off-by-one reported by Coverity
@ 2016-04-04 10:22 Leon Alrae
0 siblings, 0 replies; only message in thread
From: Leon Alrae @ 2016-04-04 10:22 UTC (permalink / raw)
To: qemu-devel; +Cc: pbonzini
Fix off-by-one error in ITC Tag read.
Remove the switch as we just want to check if index is in valid range
rather than test against list of values.
Signed-off-by: Leon Alrae <leon.alrae@imgtec.com>
---
hw/misc/mips_itu.c | 11 +++--------
1 file changed, 3 insertions(+), 8 deletions(-)
diff --git a/hw/misc/mips_itu.c b/hw/misc/mips_itu.c
index 8461d23..da54550 100644
--- a/hw/misc/mips_itu.c
+++ b/hw/misc/mips_itu.c
@@ -66,18 +66,13 @@ static uint64_t itc_tag_read(void *opaque, hwaddr addr, unsigned size)
{
MIPSITUState *tag = (MIPSITUState *)opaque;
uint64_t index = addr >> 3;
- uint64_t ret = 0;
- switch (index) {
- case 0 ... ITC_ADDRESSMAP_NUM:
- ret = tag->ITCAddressMap[index];
- break;
- default:
+ if (index >= ITC_ADDRESSMAP_NUM) {
qemu_log_mask(LOG_GUEST_ERROR, "Read 0x%" PRIx64 "\n", addr);
- break;
+ return 0;
}
- return ret;
+ return tag->ITCAddressMap[index];
}
static void itc_reconfigure(MIPSITUState *tag)
--
2.7.4
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2016-04-04 10:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-04-04 10:22 [Qemu-devel] [PATCH] hw/mips_itu: fix off-by-one reported by Coverity Leon Alrae
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).