PCI: fix reference leak in pci_get_dev_by_id()
authorGreg KH <[email protected]>
Thu, 21 Aug 2008 20:47:58 +0000 (13:47 -0700)
committerJesse Barnes <[email protected]>
Thu, 21 Aug 2008 22:22:46 +0000 (15:22 -0700)
Alex Chiang and Matthew Wilcox pointed out that pci_get_dev_by_id() does
not properly decrement the reference on the from pointer if it is
present, like the documentation for the function states it will.

It fixes a pretty bad leak in the hotplug core (we were leaking an
entire struct pci_dev for each function of each offlined card, the first
time around; subsequent onlines/offlines were ok).

Cc: Matthew Wilcox <[email protected]>
Cc: stable <[email protected]>
Tested-by: Alex Chiang <[email protected]>
Acked-by: Alex Chiang <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
Signed-off-by: Jesse Barnes <[email protected]>
drivers/pci/search.c

index 217814fef4ef4c7e5b3e4b54b96b1e70c7e2b7d4..3b3b5f1787973556f7dacecd01b1ab3bbe68b68f 100644 (file)
@@ -280,6 +280,8 @@ static struct pci_dev *pci_get_dev_by_id(const struct pci_device_id *id,
                              match_pci_dev_by_id);
        if (dev)
                pdev = to_pci_dev(dev);
+       if (from)
+               pci_dev_put(from);
        return pdev;
 }