diff options
author | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2020-08-06 15:09:45 +0200 |
---|---|---|
committer | Laurent Vivier <laurent@vivier.eu> | 2020-09-01 09:28:28 +0200 |
commit | f234501c67234d54dc75f34eb76988c929778070 (patch) | |
tree | 882c2b1c63ce38cf157063edf26798bc9145341f /hw/core/sysbus.c | |
parent | cc6498ec6e9e11c0b2d055efbf2f2bc518c73b3a (diff) |
hw/core/sysbus: Assert memory region index is in range
Devices incorrectly modelled might use invalid index while
calling sysbus_mmio_get_region(), leading to OOB access.
Help developers by asserting the index is in range.
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>
Message-Id: <20200806130945.21629-3-f4bug@amsat.org>
Signed-off-by: Laurent Vivier <laurent@vivier.eu>
Diffstat (limited to 'hw/core/sysbus.c')
-rw-r--r-- | hw/core/sysbus.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 77ab351ce1..294f90b7de 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -199,6 +199,7 @@ void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory) MemoryRegion *sysbus_mmio_get_region(SysBusDevice *dev, int n) { + assert(n >= 0 && n < QDEV_MAX_MMIO); return dev->mmio[n].memory; } |