powerpc/eeh: Fix crash when edev->pdev changes
authorSam Bobroff <sbobroff@linux.ibm.com>
Fri, 16 Aug 2019 04:48:14 +0000 (14:48 +1000)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 22 Aug 2019 13:12:47 +0000 (23:12 +1000)
commit2e25505147b8acf6510b9d5d951fd4c75f2e9bf2
tree6dc69c04484fb510f6ad970348d9a6c835002a86
parent1ff8f36fc770dd2b3eb294312f270db8cf94cc13
powerpc/eeh: Fix crash when edev->pdev changes

If a PCI device is removed during eeh_pe_report_edev(), between the
calls to device_lock() and device_unlock(), edev->pdev will change and
cause a crash as the wrong mutex is released.

To correct this, hold the PCI rescan/remove lock while taking a copy
of edev->pdev and performing a get_device() on it.  Use this value to
release the mutex, but also pass it through to the device driver's EEH
handlers so that they always see the same device.

Signed-off-by: Sam Bobroff <sbobroff@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/3c590579a0faa24d20c826dcd26c739eb4d454e6.1565930772.git.sbobroff@linux.ibm.com
arch/powerpc/kernel/eeh_driver.c