aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/i7300_edac.c
diff options
context:
space:
mode:
authorJean Delvare <jdelvare@suse.de>2014-02-25 03:43:13 -0500
committerBorislav Petkov <bp@suse.de>2014-02-25 03:43:13 -0500
commit75135da0d68419ef8a925f4c1d5f63d8046e314d (patch)
treedb9f21d3b0131bcd7c23c510852ad4143a44f1a4 /drivers/edac/i7300_edac.c
parentc0f5eeed0f4cef4f05b74883a7160e7edde58b6a (diff)
i7300_edac: Fix device reference count
pci_get_device() decrements the reference count of "from" (last argument) so when we break off the loop successfully we have only one device reference - and we don't know which device we have. If we want a reference to each device, we must take them explicitly and let the pci_get_device() walk complete to avoid duplicate references. This is serious, as over-putting device references will cause the device to eventually disappear. Without this fix, the kernel crashes after a few insmod/rmmod cycles. Tested on an Intel S7000FC4UR system with a 7300 chipset. Signed-off-by: Jean Delvare <jdelvare@suse.de> Link: http://lkml.kernel.org/r/20140224111656.09bbb7ed@endymion.delvare 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/i7300_edac.c')
-rw-r--r--drivers/edac/i7300_edac.c38
1 files changed, 20 insertions, 18 deletions
diff --git a/drivers/edac/i7300_edac.c b/drivers/edac/i7300_edac.c
index d63f4798f7d0..57e96a3350f0 100644
--- a/drivers/edac/i7300_edac.c
+++ b/drivers/edac/i7300_edac.c
@@ -943,33 +943,35 @@ static int i7300_get_devices(struct mem_ctl_info *mci)
943 943
944 /* Attempt to 'get' the MCH register we want */ 944 /* Attempt to 'get' the MCH register we want */
945 pdev = NULL; 945 pdev = NULL;
946 while (!pvt->pci_dev_16_1_fsb_addr_map || 946 while ((pdev = pci_get_device(PCI_VENDOR_ID_INTEL,
947 !pvt->pci_dev_16_2_fsb_err_regs) { 947 PCI_DEVICE_ID_INTEL_I7300_MCH_ERR,
948 pdev = pci_get_device(PCI_VENDOR_ID_INTEL, 948 pdev))) {
949 PCI_DEVICE_ID_INTEL_I7300_MCH_ERR, pdev);
950 if (!pdev) {
951 /* End of list, leave */
952 i7300_printk(KERN_ERR,
953 "'system address,Process Bus' "
954 "device not found:"
955 "vendor 0x%x device 0x%x ERR funcs "
956 "(broken BIOS?)\n",
957 PCI_VENDOR_ID_INTEL,
958 PCI_DEVICE_ID_INTEL_I7300_MCH_ERR);
959 goto error;
960 }
961
962 /* Store device 16 funcs 1 and 2 */ 949 /* Store device 16 funcs 1 and 2 */
963 switch (PCI_FUNC(pdev->devfn)) { 950 switch (PCI_FUNC(pdev->devfn)) {
964 case 1: 951 case 1:
965 pvt->pci_dev_16_1_fsb_addr_map = pdev; 952 if (!pvt->pci_dev_16_1_fsb_addr_map)
953 pvt->pci_dev_16_1_fsb_addr_map =
954 pci_dev_get(pdev);
966 break; 955 break;
967 case 2: 956 case 2:
968 pvt->pci_dev_16_2_fsb_err_regs = pdev; 957 if (!pvt->pci_dev_16_2_fsb_err_regs)
958 pvt->pci_dev_16_2_fsb_err_regs =
959 pci_dev_get(pdev);
969 break; 960 break;
970 } 961 }
971 } 962 }
972 963
964 if (!pvt->pci_dev_16_1_fsb_addr_map ||
965 !pvt->pci_dev_16_2_fsb_err_regs) {
966 /* At least one device was not found */
967 i7300_printk(KERN_ERR,
968 "'system address,Process Bus' device not found:"
969 "vendor 0x%x device 0x%x ERR funcs (broken BIOS?)\n",
970 PCI_VENDOR_ID_INTEL,
971 PCI_DEVICE_ID_INTEL_I7300_MCH_ERR);
972 goto error;
973 }
974
973 edac_dbg(1, "System Address, processor bus- PCI Bus ID: %s %x:%x\n", 975 edac_dbg(1, "System Address, processor bus- PCI Bus ID: %s %x:%x\n",
974 pci_name(pvt->pci_dev_16_0_fsb_ctlr), 976 pci_name(pvt->pci_dev_16_0_fsb_ctlr),
975 pvt->pci_dev_16_0_fsb_ctlr->vendor, 977 pvt->pci_dev_16_0_fsb_ctlr->vendor,