All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Berger <stefanb@linux.ibm.com>
To: qemu-devel@nongnu.org
Cc: peter.maydell@linaro.org, Mohammadfaiz Bawa <mbawa@redhat.com>,
	Stefan Berger <stefanb@linux.ibm.com>
Subject: [PULL v1 1/3] hw/core/platform-bus: guard platform_bus_get_mmio_addr() against NULL
Date: Fri, 10 Jul 2026 10:41:06 -0400	[thread overview]
Message-ID: <20260710144108.621828-2-stefanb@linux.ibm.com> (raw)
In-Reply-To: <20260710144108.621828-1-stefanb@linux.ibm.com>

From: Mohammadfaiz Bawa <mbawa@redhat.com>

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>
---
 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.55.0



  reply	other threads:[~2026-07-10 14:41 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-10 14:41 [PULL v1 0/3] Merge tpm 2026/07/10 v1 Stefan Berger
2026-07-10 14:41 ` Stefan Berger [this message]
2026-07-10 14:41 ` [PULL v1 2/3] hw/tpm: gate PPI support on tpm-tis-device behind a device property Stefan Berger
2026-07-10 14:41 ` [PULL v1 3/3] hw/core/machine: disable tpm-tis-device PPI for machine type <= 11.0 Stefan Berger
2026-07-11  8:39 ` [PULL v1 0/3] Merge tpm 2026/07/10 v1 Stefan Hajnoczi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260710144108.621828-2-stefanb@linux.ibm.com \
    --to=stefanb@linux.ibm.com \
    --cc=mbawa@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.