[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 06/49] spapr_pci: Fix potential NULL pointer derefere
From: |
David Gibson |
Subject: |
[Qemu-devel] [PULL 06/49] spapr_pci: Fix potential NULL pointer dereference in spapr_dt_pci_bus() |
Date: |
Tue, 2 Jul 2019 16:08:14 +1000 |
From: Philippe Mathieu-Daudé <address@hidden>
Commit 14e714900f6 refactored the call to spapr_dt_drc(),
introducing a potential NULL pointer dereference while
accessing bus->parent_dev.
A trivial audit show 'bus' is not null in the two places
the static function spapr_dt_drc() is called.
Since the 'bus' parameter is not NULL in both callers, remove
remove the test on if (bus), and add an assert() to silent
static analyzers.
This fixes:
/hw/ppc/spapr_pci.c: 1367 in spapr_dt_pci_bus()
>>> CID 1401933: Null pointer dereferences (FORWARD_NULL)
>>> Dereferencing null pointer "bus".
1367 ret = spapr_dt_drc(fdt, offset, OBJECT(bus->parent_dev),
1368 SPAPR_DR_CONNECTOR_TYPE_PCI);
Fixes: 14e714900f6
Reported-by: Coverity (CID 1401933)
Suggested-by: Greg Kurz <address@hidden>
Suggested-by: David Gibson <address@hidden>
Signed-off-by: Philippe Mathieu-Daudé <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr_pci.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 957ae88bbd..fbeb1c90ee 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1356,12 +1356,11 @@ static int spapr_dt_pci_bus(SpaprPhbState *sphb, PCIBus
*bus,
_FDT(fdt_setprop_cell(fdt, offset, "#size-cells",
RESOURCE_CELLS_SIZE));
- if (bus) {
- pci_for_each_device_reverse(bus, pci_bus_num(bus),
- spapr_dt_pci_device_cb, &cbinfo);
- if (cbinfo.err) {
- return cbinfo.err;
- }
+ assert(bus);
+ pci_for_each_device_reverse(bus, pci_bus_num(bus),
+ spapr_dt_pci_device_cb, &cbinfo);
+ if (cbinfo.err) {
+ return cbinfo.err;
}
ret = spapr_dt_drc(fdt, offset, OBJECT(bus->parent_dev),
--
2.21.0
- [Qemu-devel] [PULL 03/49] ppc/pnv: fix StoreEOI activation, (continued)
- [Qemu-devel] [PULL 03/49] ppc/pnv: fix StoreEOI activation, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 02/49] docs: updates on the POWER9 XIVE interrupt controller documentation, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 07/49] xics/spapr: Prevent RTAS/hypercalls emulation to be used by in-kernel XICS, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 09/49] xics/spapr: Detect old KVM XICS on POWER9 hosts, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 05/49] ppc/pnv: remove xscom_base field from PnvChip, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 04/49] ppc/pnv: fix XSCOM MMIO base address for P9 machines with multiple chips, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 10/49] target/ppc: fix compile error in kvmppc_define_rtas_kernel_token(), David Gibson, 2019/07/02
- [Qemu-devel] [PULL 14/49] spapr_pci: Fix DRC owner in spapr_dt_pci_bus(), David Gibson, 2019/07/02
- [Qemu-devel] [PULL 18/49] hw/ppc/mac_newworld: Drop useless CONFIG_KVM ifdefery, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 16/49] spapr_pci: Drop useless CONFIG_KVM ifdefery, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 06/49] spapr_pci: Fix potential NULL pointer dereference in spapr_dt_pci_bus(),
David Gibson <=
- [Qemu-devel] [PULL 13/49] target/ppc: remove getVSR()/putVSR() from mem_helper.c, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 08/49] xics/spapr: Register RTAS/hypercalls once at machine init, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 17/49] hw/ppc/mac_oldworld: Drop useless CONFIG_KVM ifdefery, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 15/49] xics/spapr: Only emulated XICS should use RTAS/hypercalls emulation, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 29/49] target/ppc: remove getVSR()/putVSR() from int_helper.c, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 25/49] xics/kvm: Add error propagation to ic*_set_kvm_state() functions, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 22/49] xics/spapr: Rename xics_kvm_init(), David Gibson, 2019/07/02
- [Qemu-devel] [PULL 11/49] xics: Add comment about CPU hotplug, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 12/49] target/ppc: remove getVSR()/putVSR() from fpu_helper.c, David Gibson, 2019/07/02
- [Qemu-devel] [PULL 20/49] hw/ppc: Drop useless CONFIG_KVM ifdefery, David Gibson, 2019/07/02