Skip to contentSkip to conversation

Incorrect IO index overflow check

Qemu-devel Paul Brook 1 participant 1 message Oct 29, 2005

lore
Share & tools
lore

Paul Brook

author
#0 lore raw

The attached patch fixes an incorrect overflow check in cpu_register_io_memory.

Paul

Index: exec.c
===================================================================
RCS file: /cvsroot/qemu/qemu/exec.c,v
retrieving revision 1.65

exec.c +3 -6
diff -u -p -r1.65 exec.c
@@ -2095,14 +2095,11 @@ int cpu_register_io_memory(int io_index,
     int i;
 
     if (io_index <= 0) {
-        if (io_index >= IO_MEM_NB_ENTRIES)
-            return -1;
         io_index = io_mem_nb++;
-    } else {
-        if (io_index >= IO_MEM_NB_ENTRIES)
-            return -1;
     }
-    
+    if (io_index >= IO_MEM_NB_ENTRIES)
+        return -1;
+
     for(i = 0;i < 3; i++) {
         io_mem_read[io_index][i] = mem_read[i];
         io_mem_write[io_index][i] = mem_write[i];