]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
hw/pcspk: check the "pit" is set
authorMarc-André Lureau <marcandre.lureau@redhat.com>
Tue, 21 Oct 2025 09:02:37 +0000 (13:02 +0400)
committerPhilippe Mathieu-Daudé <philmd@linaro.org>
Wed, 22 Oct 2025 06:55:28 +0000 (08:55 +0200)
We don't let the user create a "isa-pcspk" via -device yet (in theory,
we could, and fallback on a lookup PIT), but we can add some safety
checks that the property was correctly set nonetheless.

Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20251021090317.425409-7-marcandre.lureau@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
hw/audio/pcspk.c

index 7b716c08efc9586c17591640b477bdb4e3bb4ec3..54fcf632e6a677e4e9214e6c824145bb0966c928 100644 (file)
@@ -189,6 +189,11 @@ static void pcspk_realizefn(DeviceState *dev, Error **errp)
     ISADevice *isadev = ISA_DEVICE(dev);
     PCSpkState *s = PC_SPEAKER(dev);
 
+    if (!s->pit) {
+        error_setg(errp, "pcspk: No \"pit\" set or available");
+        return;
+    }
+
     isa_register_ioport(isadev, &s->ioport, s->iobase);
 
     if (s->card.state && AUD_register_card(s_spk, &s->card, errp)) {