Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc/eeh: Null check uses of eeh_pe_bus_get

eeh_pe_bus_get() can return NULL if a PCI bus isn't found for a given PE.
Some callers don't check this, and can cause a null pointer dereference
under certain circumstances.

Fix this by checking NULL everywhere eeh_pe_bus_get() is called.

Fixes: 8a6b1bc70dbb ("powerpc/eeh: EEH core to handle special event")
Cc: stable@vger.kernel.org # v3.11+
Signed-off-by: Russell Currey <ruscur@russell.cc>
Reviewed-by: Andrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>

authored by

Russell Currey and committed by
Michael Ellerman
04fec21c a24553dd

+13
+8
arch/powerpc/kernel/eeh_driver.c
··· 994 994 /* Notify all devices to be down */ 995 995 eeh_pe_state_clear(pe, EEH_PE_PRI_BUS); 996 996 bus = eeh_pe_bus_get(phb_pe); 997 + if (!bus) { 998 + pr_err("%s: Cannot find PCI bus for " 999 + "PHB#%d-PE#%x\n", 1000 + __func__, 1001 + pe->phb->global_number, 1002 + pe->addr); 1003 + break; 1004 + } 997 1005 eeh_pe_dev_traverse(pe, 998 1006 eeh_report_failure, NULL); 999 1007 pci_hp_remove_devices(bus);
+5
arch/powerpc/platforms/powernv/eeh-powernv.c
··· 1091 1091 } 1092 1092 1093 1093 bus = eeh_pe_bus_get(pe); 1094 + if (!bus) { 1095 + pr_err("%s: Cannot find PCI bus for PHB#%d-PE#%x\n", 1096 + __func__, pe->phb->global_number, pe->addr); 1097 + return -EIO; 1098 + } 1094 1099 if (pe->type & EEH_PE_VF) 1095 1100 return pnv_eeh_reset_vf_pe(pe, option); 1096 1101