]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
powerpc/pseries/eeh: Fix crash when error happens during device probe
authorThadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
Wed, 11 Jan 2012 09:09:58 +0000 (09:09 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Tue, 14 Feb 2012 04:01:39 +0000 (15:01 +1100)
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: Thadeu Lima de Souza Cascardo <cascardo@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/include/asm/ppc-pci.h
arch/powerpc/platforms/pseries/eeh.c

index 43268f15004e8082148cc1a57de8766fdad75c7d..6d422979ebafde984906f20add7886fd9e1464ec 100644 (file)
@@ -142,6 +142,11 @@ static inline const char *eeh_pci_name(struct pci_dev *pdev)
        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 */
 
 #else /* CONFIG_PCI */
index 565869022e3d4e54c603cc6b2f79afb7fe6c2bd2..c0b40af4ce4f130edbd094d48467f747a10d78cc 100644 (file)
@@ -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 "
                                "location=%s driver=%s pci addr=%s\n",
                                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",
-                               dev->driver->name);
+                               eeh_driver_name(dev));
                        dump_stack();
                }
                goto dn_unlock;