[Skiboot] [PATCH 2/4] core/pcie-slots: Fix coverity possible NULL dereference

Cyril Bur cyril.bur at au1.ibm.com
Thu Nov 9 11:44:09 AEDT 2017


Coverity has found a senario where there could be a NULL dereference,
it is likely that in practice we wouldn't hit this. Coverity does point
out that all other callers of pcie_slot_create() do check for the NULL
return, as such it makes sense to add a check.

Fixes: CID 173756
Signed-off-by: Cyril Bur <cyril.bur at au1.ibm.com>
---
 core/pcie-slot.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/core/pcie-slot.c b/core/pcie-slot.c
index 77e356c8..c3069040 100644
--- a/core/pcie-slot.c
+++ b/core/pcie-slot.c
@@ -575,8 +575,9 @@ struct pci_slot *pcie_slot_create_dynamic(struct phb *phb,
 	 *
 	 * We have same issue with PEX8718 as above on "p8dnu" platform.
 	 */
-	if (dt_node_is_compatible(dt_root, "supermicro,p8dnu") && slot->pd &&
-	    (slot->pd->vdid == 0x973310b5 || slot->pd->vdid == 0x871810b5))
+	if (dt_node_is_compatible(dt_root, "supermicro,p8dnu") && slot &&
+	    slot->pd && (slot->pd->vdid == 0x973310b5 ||
+	    slot->pd->vdid == 0x871810b5))
 		pci_slot_add_flags(slot, PCI_SLOT_FLAG_FORCE_POWERON);
 
 	return slot;
-- 
2.15.0



More information about the Skiboot mailing list