hw/core/platform-bus: guard platform_bus_get_mmio_addr() against NULL

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 <peter.maydell@linaro.org>
Signed-off-by: Mohammadfaiz Bawa <mbawa@redhat.com>
Link: https://lore.kernel.org/qemu-devel/20260619093140.832136-2-mbawa@redhat.com
Signed-off-by: Stefan Berger <stefanb@linux.ibm.com>
This commit is contained in:
Mohammadfaiz Bawa
2026-06-19 15:01:38 +05:30
committed by Stefan Berger
parent ab2056a0b7
commit fb7609c4bf

View File

@@ -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;
}