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>
This commit is contained in:
parent
cc6498ec6e
commit
f234501c67
@ -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;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user