sysbus_mmio_get_region() returns NULL when a device has fewer MMIO regions than the requested slot index. platform_bus_get_mmio_addr() passes the result directly to memory_region_is_mapped() without a NULL check, causing a SIGSEGV.
Return -1 early when the region pointer is NULL, consistent with the existing "not mapped" path. Reviewed-by: Peter Maydell <[email protected]> Signed-off-by: Mohammadfaiz Bawa <[email protected]> --- hw/core/platform-bus.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/hw/core/platform-bus.c b/hw/core/platform-bus.c index a2217a2dee..16d0ecc0f3 100644 --- a/hw/core/platform-bus.c +++ b/hw/core/platform-bus.c @@ -59,8 +59,7 @@ hwaddr platform_bus_get_mmio_addr(PlatformBusDevice *pbus, SysBusDevice *sbdev, Object *pbus_mr_obj = OBJECT(pbus_mr); Object *parent_mr; - if (!memory_region_is_mapped(sbdev_mr)) { - /* Region is not mapped? */ + if (!sbdev_mr || !memory_region_is_mapped(sbdev_mr)) { return -1; } -- 2.54.0
