All of lore.kernel.org
 help / color / mirror / Atom feed
From: Luigi Leonardi <leonardi@redhat.com>
To: qemu-devel@nongnu.org
Cc: Paolo Bonzini <pbonzini@redhat.com>,
	 "Michael S. Tsirkin" <mst@redhat.com>,
	 Richard Henderson <richard.henderson@linaro.org>,
	 Sergio Lopez <slp@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>,
	 Luigi Leonardi <leonardi@redhat.com>
Subject: [PATCH 1/3] hw/core/platform-bus: fix crash when num_irqs is zero
Date: Wed, 01 Jul 2026 16:16:17 +0200	[thread overview]
Message-ID: <20260701-microvm_uefi_var-v1-1-0652cae6a152@redhat.com> (raw)
In-Reply-To: <20260701-microvm_uefi_var-v1-0-0652cae6a152@redhat.com>

bitmap_new(0) returns a zero-size allocation, and the subsequent
bitmap_zero() dereferences it because small_nbits(0) is true.
Skip IRQ initialization entirely when num_irqs is zero, which is
valid for platform buses that only provide MMIO mapping.

This will be the case for the microvm platform bus which initially
has no IRQ lines.

Signed-off-by: Luigi Leonardi <leonardi@redhat.com>
---
 hw/core/platform-bus.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/hw/core/platform-bus.c b/hw/core/platform-bus.c
index a2217a2dee..4f765582e7 100644
--- a/hw/core/platform-bus.c
+++ b/hw/core/platform-bus.c
@@ -194,6 +194,10 @@ static void platform_bus_realize(DeviceState *dev, Error **errp)
                        pbus->mmio_size);
     sysbus_init_mmio(d, &pbus->mmio);
 
+    if (pbus->num_irqs == 0) {
+        return;
+    }
+
     pbus->used_irqs = bitmap_new(pbus->num_irqs);
     pbus->irqs = g_new0(qemu_irq, pbus->num_irqs);
     for (i = 0; i < pbus->num_irqs; i++) {

-- 
2.54.0



  reply	other threads:[~2026-07-01 14:17 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-01 14:16 [PATCH 0/3] hw/i386/microvm: add uefi-vars-sysbus support via platform bus Luigi Leonardi
2026-07-01 14:16 ` Luigi Leonardi [this message]
2026-07-01 14:16 ` [PATCH 2/3] hw/i386/microvm: add platform bus support Luigi Leonardi
2026-07-01 14:16 ` [PATCH 3/3] hw/i386/microvm: add uefi-vars-sysbus support Luigi Leonardi
2026-08-17 15:01 ` [PATCH 0/3] hw/i386/microvm: add uefi-vars-sysbus support via platform bus Luigi Leonardi

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=20260701-microvm_uefi_var-v1-1-0652cae6a152@redhat.com \
    --to=leonardi@redhat.com \
    --cc=kraxel@redhat.com \
    --cc=mst@redhat.com \
    --cc=pbonzini@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=slp@redhat.com \
    /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.