powerpc/eeh: Fix null deref for devices removed during EEH
authorSam Bobroff <sbobroff@linux.ibm.com>
Wed, 12 Sep 2018 01:23:21 +0000 (11:23 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 13 Oct 2018 11:21:25 +0000 (22:21 +1100)
If a device is removed during EEH processing (either by a driver's
handler or as part of recovery), it can lead to a null dereference
in eeh_pe_report_edev().

To handle this, skip devices that have been removed.

Signed-off-by: Sam Bobroff <sbobroff@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/kernel/eeh_driver.c

index 67619b4b3f96c721993ce8b94b0f56cca6b4f418..4115d353c34924224c081f15e6adc30205928af1 100644 (file)
@@ -281,6 +281,10 @@ static void eeh_pe_report_edev(struct eeh_dev *edev, eeh_report_fn fn,
        struct pci_driver *driver;
        enum pci_ers_result new_result;
 
+       if (!edev->pdev) {
+               eeh_edev_info(edev, "no device");
+               return;
+       }
        device_lock(&edev->pdev->dev);
        if (eeh_edev_actionable(edev)) {
                driver = eeh_pcid_get(edev->pdev);