]> git.proxmox.com Git - mirror_qemu.git/commitdiff
hw/omap_intc.c: Avoid crash on access to nonexistent banked registers
authorPeter Maydell <peter.maydell@linaro.org>
Wed, 9 Nov 2011 18:45:38 +0000 (18:45 +0000)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 11 Nov 2011 18:49:52 +0000 (12:49 -0600)
Avoid a crash due to null pointer dereference if a guest attempts
to access banked registers for a nonexistent bank. Spotted by
Coverity (see bug 887883).

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/omap_intc.c

index 0f7fd9dd4c105c63ef20d05f413533842dd08169..45efa25109941bbef180def3a5cd9937b35ff998 100644 (file)
@@ -398,6 +398,9 @@ static uint64_t omap2_inth_read(void *opaque, target_phys_addr_t addr,
         if (bank_no < s->nbanks) {
             offset &= ~0x60;
             bank = &s->bank[bank_no];
+        } else {
+            OMAP_BAD_REG(addr);
+            return 0;
         }
     }
 
@@ -476,6 +479,9 @@ static void omap2_inth_write(void *opaque, target_phys_addr_t addr,
         if (bank_no < s->nbanks) {
             offset &= ~0x60;
             bank = &s->bank[bank_no];
+        } else {
+            OMAP_BAD_REG(addr);
+            return;
         }
     }