On Fri, 19 Jun 2026 at 06:36, Mohammadfaiz Bawa <[email protected]> wrote: > > 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. > > 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; > }
Reviewed-by: Peter Maydell <[email protected]> but doesn't this need to come earlier in the series, so that the code can handle the NULL pointer before we change the device/machine to not expose the 2nd MR? thanks -- PMM
