qemu-patch-raspberry4/hw/pci
Thomas Huth 4d0ecde44a pci: Fix crash with illegal "-net nic, model=xxx" option
Current QEMU crashes when specifying an illegal model with the
"-net nic,model=xxx" option, e.g.:

 $ qemu-system-x86_64 -net nic,model=n/a
 qemu-system-x86_64: Unsupported NIC model: n/a

 Program received signal SIGSEGV, Segmentation fault.

The gdb backtrace looks like this:

0x0000555555965fe0 in error_get_pretty (err=0x0) at util/error.c:152
152	    return err->msg;
(gdb) bt
 0  0x0000555555965fe0 in error_get_pretty (err=0x0) at util/error.c:152
 1  0x0000555555965ffd in error_report_err (err=0x0) at util/error.c:157
 2  0x0000555555809c90 in pci_nic_init_nofail (nd=0x555555e49860 <nd_table>, rootbus=0x5555564409b0,
    default_model=0x55555598c37b "e1000", default_devaddr=0x0) at hw/pci/pci.c:1663
 3  0x0000555555691e42 in pc_nic_init (isa_bus=0x555556f71900, pci_bus=0x5555564409b0)
    at hw/i386/pc.c:1506
 4  0x000055555569396b in pc_init1 (machine=0x5555562abbf0, pci_enabled=1, kvmclock_enabled=1)
    at hw/i386/pc_piix.c:248
 5  0x0000555555693d27 in pc_init_pci (machine=0x5555562abbf0) at hw/i386/pc_piix.c:310
 6  0x000055555572ddf5 in main (argc=3, argv=0x7fffffffe018, envp=0x7fffffffe038) at vl.c:4226

The problem is that pci_nic_init_nofail() does not check whether the err
parameter from pci_nic_init has been set up and thus passes a NULL pointer
to error_report_err(). Fix it by correctly checking the err parameter.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Jason Wang <jasowang@redhat.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
2015-04-13 12:11:44 +01:00
..
Makefile.objs pci-hotplug-old: Has been dead for five major releases, bury 2015-03-01 12:37:54 +01:00
msi.c pci: Use bus master address space for delivering MSI/MSI-X messages 2014-08-14 13:20:33 +02:00
msix.c SCSI changes that enable sending vendor-specific commands via virtio-scsi. 2014-08-19 13:00:57 +01:00
pci-stub.c hmp: Name HMP command handler functions hmp_COMMAND() 2015-02-18 11:58:30 +01:00
pci.c pci: Fix crash with illegal "-net nic, model=xxx" option 2015-04-13 12:11:44 +01:00
pci_bridge.c pci_bridge: manually destroy memory regions within PCIBridgeWindows 2014-08-25 00:16:06 +02:00
pci_host.c hw/pci/pci_host.c: Avoid shifting left into sign bit 2014-03-27 19:22:49 +04:00
pcie.c pcie: correct mistaken register bit for End-End TLP Prefix Blocking 2015-03-18 12:14:45 +01:00
pcie_aer.c pcie_aer: fix comment to match pcie spec 2015-03-18 12:48:21 +01:00
pcie_host.c pcie: remove mmconfig memory leak and wrap mmconfig update with transaction 2015-02-16 17:24:53 +01:00
pcie_port.c qdev: HotplugHandler: Rename unplug callback to unplug_request 2014-10-15 05:03:13 +02:00
shpc.c pci/shpc: fix signed integer overflow 2015-03-11 15:59:57 +01:00
slotid_cap.c hw: move qdev-monitor.o to toplevel directory 2013-03-01 13:54:10 +01:00