[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Stable-9.0.4 59/71] hw/i386/pc: Don't try to init PCI NICs if there is
From: |
Michael Tokarev |
Subject: |
[Stable-9.0.4 59/71] hw/i386/pc: Don't try to init PCI NICs if there is no PCI bus |
Date: |
Tue, 19 Nov 2024 00:08:16 +0300 |
From: Peter Maydell <peter.maydell@linaro.org>
The 'isapc' machine type has no PCI bus, but pc_nic_init() still
calls pci_init_nic_devices() passing it a NULL bus pointer. This
causes the clang sanitizer to complain:
$ ./build/clang/qemu-system-i386 -M isapc
../../hw/pci/pci.c:1866:39: runtime error: member access within null pointer of
type 'PCIBus' (aka 'struct PCIBus')
SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior
../../hw/pci/pci.c:1866:39 in
This is because pci_init_nic_devices() does
&bus->qbus
which is undefined behaviour on a NULL pointer even though we're not
actually dereferencing the pointer. (We don't actually crash as
a result, so if you aren't running a sanitizer build then there
are no user-visible effects.)
Make pc_nic_init() avoid trying to initialize PCI NICs on a non-PCI
system.
Cc: qemu-stable@nongnu.org
Fixes: 8d39f9ba14d64 ("hw/i386/pc: use qemu_get_nic_info() and
pci_init_nic_devices()")
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Link:
https://lore.kernel.org/r/20241105171813.3031969-1-peter.maydell@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
(cherry picked from commit bd0e501e1a4813fa36a4cf9842aaf430323a03c3)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 5c21b0c4db..6bd2333c2e 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1280,7 +1280,9 @@ void pc_nic_init(PCMachineClass *pcmc, ISABus *isa_bus,
PCIBus *pci_bus)
}
/* Anything remaining should be a PCI NIC */
- pci_init_nic_devices(pci_bus, mc->default_nic);
+ if (pci_bus) {
+ pci_init_nic_devices(pci_bus, mc->default_nic);
+ }
rom_reset_order_override();
}
--
2.39.5
- [Stable-9.0.4 v2 00/71] Patch Round-up for stable 9.0.4, freeze on 2024-11-18, Michael Tokarev, 2024/11/18
- [Stable-9.0.4 58/71] target/i386: Fix legacy page table walk, Michael Tokarev, 2024/11/18
- [Stable-9.0.4 59/71] hw/i386/pc: Don't try to init PCI NICs if there is no PCI bus,
Michael Tokarev <=
- [Stable-9.0.4 60/71] linux-user: Fix setreuid and setregid to use direct syscalls, Michael Tokarev, 2024/11/18
- [Stable-9.0.4 61/71] target/arm: Drop user-only special case in sve_stN_r, Michael Tokarev, 2024/11/18
- [Stable-9.0.4 64/71] linux-user/arm: Reduce vdso alignment to 4k, Michael Tokarev, 2024/11/18
- [Stable-9.0.4 63/71] linux-user: Tolerate CONFIG_LSM_MMAP_MIN_ADDR, Michael Tokarev, 2024/11/18
- [Stable-9.0.4 66/71] tcg: Allow top bit of SIMD_DATA_BITS to be set in simd_desc(), Michael Tokarev, 2024/11/18
- [Stable-9.0.4 65/71] linux-user/arm: Select vdso for be8 and be32 modes, Michael Tokarev, 2024/11/18
- [Stable-9.0.4 67/71] target/i386: fix hang when using slow path for ptw_setl, Michael Tokarev, 2024/11/18
- [Stable-9.0.4 62/71] accel/tcg: Fix user-only probe_access_internal plugin check, Michael Tokarev, 2024/11/18
- [Stable-9.0.4 71/71] usb-hub: Fix handling port power control messages, Michael Tokarev, 2024/11/18
- [Stable-9.0.4 70/71] hw/audio/hda: fix memory leak on audio setup, Michael Tokarev, 2024/11/18