[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-ppc] [PULL 03/14] spapr_pci: fix potential NULL pointer dereferenc
From: |
David Gibson |
Subject: |
[Qemu-ppc] [PULL 03/14] spapr_pci: fix potential NULL pointer dereference |
Date: |
Fri, 7 Sep 2018 17:31:44 +1000 |
From: Greg Kurz <address@hidden>
Commit 2c88b098e76fd added a call to SPAPR_MACHINE_GET_CLASS(spapr) in
spapr_phb_realize() before we check spapr isn't NULL. This causes QEMU
to crash when starting a non-pseries machine with a sPAPR PHB.
This could be fixed by setting the smc variable after the null check,
but it seems more explicit to use a ternary operator to skip the call
to SPAPR_MACHINE_GET_CLASS() if spapr is NULL, since spapr_phb_realize()
will return immediately in this case.
This was reported by Coverity (CID 1395170 and 1395183).
Fixes: 2c88b098e76fde0c7fcc0476dd3f80ce58409505
Signed-off-by: Greg Kurz <address@hidden>
Reviewed-by: Cédric Le Goater <address@hidden>
Signed-off-by: David Gibson <address@hidden>
---
hw/ppc/spapr_pci.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c
index 5cd676e443..6bcb4f419b 100644
--- a/hw/ppc/spapr_pci.c
+++ b/hw/ppc/spapr_pci.c
@@ -1559,7 +1559,7 @@ static void spapr_phb_realize(DeviceState *dev, Error
**errp)
sPAPRMachineState *spapr =
(sPAPRMachineState *) object_dynamic_cast(qdev_get_machine(),
TYPE_SPAPR_MACHINE);
- sPAPRMachineClass *smc = SPAPR_MACHINE_GET_CLASS(spapr);
+ sPAPRMachineClass *smc = spapr ? SPAPR_MACHINE_GET_CLASS(spapr) : NULL;
SysBusDevice *s = SYS_BUS_DEVICE(dev);
sPAPRPHBState *sphb = SPAPR_PCI_HOST_BRIDGE(s);
PCIHostState *phb = PCI_HOST_BRIDGE(s);
--
2.17.1
- [Qemu-ppc] [PULL 08/14] mac_oldworld: implement custom FWPathProvider, (continued)
- [Qemu-ppc] [PULL 08/14] mac_oldworld: implement custom FWPathProvider, David Gibson, 2018/09/07
- [Qemu-ppc] [PULL 05/14] macio: add macio bus to help with fw path generation, David Gibson, 2018/09/07
- [Qemu-ppc] [PULL 09/14] uninorth: add ofw-addr property to allow correct fw path generation, David Gibson, 2018/09/07
- [Qemu-ppc] [PULL 06/14] macio: add addr property to macio IDE object, David Gibson, 2018/09/07
- [Qemu-ppc] [PULL 10/14] mac_newworld: implement custom FWPathProvider, David Gibson, 2018/09/07
- [Qemu-ppc] [PULL 01/14] ppc: Remove deprecated ppcemb target, David Gibson, 2018/09/07
[Qemu-ppc] [PULL 03/14] spapr_pci: fix potential NULL pointer dereference,
David Gibson <=
[Qemu-ppc] [PULL 13/14] target/ppc/kvm: set vcpu as online/offline, David Gibson, 2018/09/07
[Qemu-ppc] [PULL 12/14] Fix a deadlock case in the CPU hotplug flow, David Gibson, 2018/09/07
[Qemu-ppc] [PULL 11/14] spapr: Correct reference count on spapr-cpu-core, David Gibson, 2018/09/07
[Qemu-ppc] [PULL 07/14] grackle: set device fw_name and address for correct fw path generation, David Gibson, 2018/09/07
Re: [Qemu-ppc] [PULL 00/14] ppc-for-3.1 queue 20180907, Peter Maydell, 2018/09/24