Commit 778a785f authored by Thadeu Lima de Souza Cascardo's avatar Thadeu Lima de Souza Cascardo Committed by Benjamin Herrenschmidt

powerpc/pseries/eeh: Fix crash when error happens during device probe

EEH may happen during a PCI driver probe. If the driver is trying to
access some register in a loop, the EEH code will try to print the
driver name. But the driver pointer in struct pci_dev is not set until
probe returns successfully.

Use a function to test if the device and the driver pointer is NULL
before accessing the driver's name.
Signed-off-by: default avatarThadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 444080d1
...@@ -142,6 +142,11 @@ static inline const char *eeh_pci_name(struct pci_dev *pdev) ...@@ -142,6 +142,11 @@ static inline const char *eeh_pci_name(struct pci_dev *pdev)
return pdev ? pci_name(pdev) : "<null>"; return pdev ? pci_name(pdev) : "<null>";
} }
static inline const char *eeh_driver_name(struct pci_dev *pdev)
{
return (pdev && pdev->driver) ? pdev->driver->name : "<null>";
}
#endif /* CONFIG_EEH */ #endif /* CONFIG_EEH */
#else /* CONFIG_PCI */ #else /* CONFIG_PCI */
......
...@@ -551,9 +551,9 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev) ...@@ -551,9 +551,9 @@ int eeh_dn_check_failure(struct device_node *dn, struct pci_dev *dev)
printk (KERN_ERR "EEH: %d reads ignored for recovering device at " printk (KERN_ERR "EEH: %d reads ignored for recovering device at "
"location=%s driver=%s pci addr=%s\n", "location=%s driver=%s pci addr=%s\n",
pdn->eeh_check_count, location, pdn->eeh_check_count, location,
dev->driver->name, eeh_pci_name(dev)); eeh_driver_name(dev), eeh_pci_name(dev));
printk (KERN_ERR "EEH: Might be infinite loop in %s driver\n", printk (KERN_ERR "EEH: Might be infinite loop in %s driver\n",
dev->driver->name); eeh_driver_name(dev));
dump_stack(); dump_stack();
} }
goto dn_unlock; goto dn_unlock;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment