e752x_edac: Fix pci_dev usage count
authorAristeu Rozanski <aris@redhat.com>
Thu, 5 Dec 2013 15:37:56 +0000 (10:37 -0500)
committerBorislav Petkov <bp@suse.de>
Sat, 21 Dec 2013 12:26:57 +0000 (13:26 +0100)
In case the device 0, function 1 is not found using pci_get_device(),
pci_scan_single_device() will be used but, differently than
pci_get_device(), it allocates a pci_dev but doesn't does bump the usage
count on the pci_dev and after few module removals and loads the pci_dev
will be freed.

Signed-off-by: Aristeu Rozanski <aris@redhat.com>
Reviewed-by: mark gross <mark.gross@intel.com>
Link: http://lkml.kernel.org/r/20131205153755.GL4545@redhat.com
Signed-off-by: Borislav Petkov <bp@suse.de>
drivers/edac/e752x_edac.c

index 5fb01b03773a502149cd6b6615d1ebd1848e1ce6..92d54fa65f939d57f7f18332bed3f6d55a03d33d 100644 (file)
@@ -1182,9 +1182,11 @@ static int e752x_get_devs(struct pci_dev *pdev, int dev_idx,
        pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
                                pvt->dev_info->err_dev, pvt->bridge_ck);
 
        pvt->bridge_ck = pci_get_device(PCI_VENDOR_ID_INTEL,
                                pvt->dev_info->err_dev, pvt->bridge_ck);
 
-       if (pvt->bridge_ck == NULL)
+       if (pvt->bridge_ck == NULL) {
                pvt->bridge_ck = pci_scan_single_device(pdev->bus,
                                                        PCI_DEVFN(0, 1));
                pvt->bridge_ck = pci_scan_single_device(pdev->bus,
                                                        PCI_DEVFN(0, 1));
+               pci_dev_get(pvt->bridge_ck);
+       }
 
        if (pvt->bridge_ck == NULL) {
                e752x_printk(KERN_ERR, "error reporting device not found:"
 
        if (pvt->bridge_ck == NULL) {
                e752x_printk(KERN_ERR, "error reporting device not found:"
This page took 0.032533 seconds and 5 git commands to generate.