Commit fb7609c4bf for qemu.org
commit fb7609c4bf74e31ea06c0d8e400dd01badcfa4c3
Author: Mohammadfaiz Bawa <mbawa@redhat.com>
Date: Fri Jun 19 15:01:38 2026 +0530
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>
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;
}