diff mbox

[RFC,v1,07/25] sysbus: mmio_map+mmio_get_region: ignore range OOB errors

Message ID a01bb26317e5626123321a34a74cac4024823b49.1441667360.git.crosthwaite.peter@gmail.com
State New
Headers show

Commit Message

Peter Crosthwaite Sept. 11, 2015, 5:33 a.m. UTC
Ignore these errors as they may be a follow on effect of device
realisation failure. Ideally we should have an error ** to populate
in own right, but that requires an API change. Mark FIXME.

Signed-off-by: Peter Crosthwaite <crosthwaite.peter@gmail.com>
---

 hw/core/sysbus.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)
diff mbox

Patch

diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c
index 3c58629..6fde10e 100644
--- a/hw/core/sysbus.c
+++ b/hw/core/sysbus.c
@@ -127,7 +127,12 @@  bool sysbus_has_mmio(SysBusDevice *dev, unsigned int n)
 static void sysbus_mmio_map_common(SysBusDevice *dev, int n, hwaddr addr,
                                    bool may_overlap, int priority)
 {
-    assert(n >= 0 && n < dev->num_mmio);
+    assert(n >= 0);
+
+    if (n < dev->num_mmio) {
+        /* FIXME: Add an Error ** to this function for this condition */
+        return;
+    }
 
     if (dev->mmio[n].addr == addr) {
         /* ??? region already mapped here.  */
@@ -186,6 +191,10 @@  void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory)
 
 MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n)
 {
+    if (n >= dev->num_mmio) {
+        /* FIXME: Add an Error ** to this function for this condition */
+        return NULL;
+    }
     return dev->mmio[n].memory;
 }