]> git.ipfire.org Git - thirdparty/qemu.git/commit
hw/i386/pc: Don't try to init PCI NICs if there is no PCI bus
authorPeter Maydell <peter.maydell@linaro.org>
Tue, 5 Nov 2024 17:18:13 +0000 (17:18 +0000)
committerMichael Tokarev <mjt@tls.msk.ru>
Wed, 13 Nov 2024 15:21:29 +0000 (18:21 +0300)
commit7ca2aa5f5388fbcaea11c4e09ab4d53ff6c34b83
tree33e54b101b19d7726386352d94e02644aa3d1ce9
parent1a629dc2f20ab8a4e619cb12d69284d8641c4e56
hw/i386/pc: Don't try to init PCI NICs if there is no PCI bus

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>
hw/i386/pc.c