aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2014-02-24 03:39:27 -0500
committerBorislav Petkov <bp@suse.de>2014-02-25 02:54:45 -0500
commitc0f5eeed0f4cef4f05b74883a7160e7edde58b6a (patch)
treed0e481c5bf067bca00bf0fac156c08a07c2d24c7 /drivers/edac
parentcfbf8d4857c26a8a307fb7cd258074c9dcd8c691 (diff)
i7core_edac: Fix PCI device reference count
The reference count changes done by pci_get_device can be a little misleading when the usage diverges from the most common scheme. The reference count of the device passed as the last parameter is always decreased, even if the function returns no new device. So if we are going to try alternative device IDs, we must manually increment the device reference count before each retry. If we don't, we end up decreasing the reference count, and after a few modprobe/rmmod cycles the PCI devices will vanish. In other words and as Alan put it: without this fix the EDAC code corrupts the PCI device list. This fixes kernel bug #50491: https://bugzilla.kernel.org/show_bug.cgi?id=50491 Signed-off-by: Jean Delvare <jdelvare@suse.de> Link: http://lkml.kernel.org/r/20140224093927.7659dd9d@endymion.delvare Reviewed-by: Alan Cox <alan@linux.intel.com> Cc: Mauro Carvalho Chehab <m.chehab@samsung.com> Cc: Doug Thompson <dougthompson@xmission.com> Cc: stable@vger.kernel.org Signed-off-by: Borislav Petkov <bp@suse.de>
Diffstat (limited to 'drivers/edac')
-rw-r--r--drivers/edac/i7core_edac.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c
index 87533ca7752e..d871275196f6 100644
--- a/drivers/edac/i7core_edac.c
+++ b/drivers/edac/i7core_edac.c
@@ -1334,14 +1334,19 @@ static int i7core_get_onedevice(struct pci_dev **prev,
1334 * is at addr 8086:2c40, instead of 8086:2c41. So, we need 1334 * is at addr 8086:2c40, instead of 8086:2c41. So, we need
1335 * to probe for the alternate address in case of failure 1335 * to probe for the alternate address in case of failure
1336 */ 1336 */
1337 if (dev_descr->dev_id == PCI_DEVICE_ID_INTEL_I7_NONCORE && !pdev) 1337 if (dev_descr->dev_id == PCI_DEVICE_ID_INTEL_I7_NONCORE && !pdev) {
1338 pci_dev_get(*prev); /* pci_get_device will put it */
1338 pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 1339 pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
1339 PCI_DEVICE_ID_INTEL_I7_NONCORE_ALT, *prev); 1340 PCI_DEVICE_ID_INTEL_I7_NONCORE_ALT, *prev);
1341 }
1340 1342
1341 if (dev_descr->dev_id == PCI_DEVICE_ID_INTEL_LYNNFIELD_NONCORE && !pdev) 1343 if (dev_descr->dev_id == PCI_DEVICE_ID_INTEL_LYNNFIELD_NONCORE &&
1344 !pdev) {
1345 pci_dev_get(*prev); /* pci_get_device will put it */
1342 pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 1346 pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
1343 PCI_DEVICE_ID_INTEL_LYNNFIELD_NONCORE_ALT, 1347 PCI_DEVICE_ID_INTEL_LYNNFIELD_NONCORE_ALT,
1344 *prev); 1348 *prev);
1349 }
1345 1350
1346 if (!pdev) { 1351 if (!pdev) {
1347 if (*prev) { 1352 if (*prev) {