[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 13/13] hw/i386/pc: Don't try to init PCI NICs if there is no PCI b
From: |
Paolo Bonzini |
Subject: |
[PULL 13/13] hw/i386/pc: Don't try to init PCI NICs if there is no PCI bus |
Date: |
Fri, 8 Nov 2024 18:38:28 +0100 |
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:
20241105171813.3031969-1-peter.maydell@linaro.org">https://lore.kernel.org/r/20241105171813.3031969-1-peter.maydell@linaro.org
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
hw/i386/pc.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 830614d9303..f9147fecbdc 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1252,7 +1252,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.47.0
- [PULL 05/13] eif: cope with huge section offsets, (continued)
- [PULL 05/13] eif: cope with huge section offsets, Paolo Bonzini, 2024/11/08
- [PULL 07/13] i386/hvf: Integrates x2APIC support with hvf accel, Paolo Bonzini, 2024/11/08
- [PULL 06/13] eif: cope with huge section sizes, Paolo Bonzini, 2024/11/08
- [PULL 09/13] i386/hvf: Fixes startup memory leak (vmcs caps), Paolo Bonzini, 2024/11/08
- [PULL 08/13] i386/hvf: Fix for UB in handling CPUID function 0xD, Paolo Bonzini, 2024/11/08
- [PULL 10/13] i386/hvf: Raise exception on error setting APICBASE, Paolo Bonzini, 2024/11/08
- [PULL 12/13] rust: qemu-api-macros: always process subprojects before dependencies, Paolo Bonzini, 2024/11/08
- [PULL 11/13] i386/hvf: Removes duplicate/shadowed variables in hvf_vcpu_exec, Paolo Bonzini, 2024/11/08
- [PULL 13/13] hw/i386/pc: Don't try to init PCI NICs if there is no PCI bus,
Paolo Bonzini <=