From: Julia Lawall Date: Sun, 23 Nov 2008 08:08:28 +0000 (+0100) Subject: drivers/pci/hotplug: Add missing pci_dev_get X-Git-Tag: v2.6.29-rc1~181^2~81 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=4ba7d0f0eb68cf7731ead4ca20e540d0266cfa8e;p=linux-2.6-omap-h63xx.git drivers/pci/hotplug: Add missing pci_dev_get pci_get_slot does a pci_dev_get, so pci_dev_put needs to be called in an error case. An alterative would be to move the test_and_set_bit before the call to pci_get_slot. The problem was fixed using the following semantic patch. (http://www.emn.fr/x-info/coccinelle/) // @@ local idexpression *n; statement S1,S2; expression E,E1; expression *ptr != NULL; type T,T1; @@ ( if (!(n = pci_get_slot(...))) S1 | n = pci_get_slot(...) ) <... when != pci_dev_put(n) when != if (...) { <+... pci_dev_put(n) ...+> } when != true !n || ... when != n = (T)E when != E = n if (!n || ...) S2 ...> ( return \(0\|<+...n...+>\|ptr\); | + pci_dev_put(n); return ...; | pci_dev_put(n); | n = (T1)E1 | E1 = n ) // Signed-off-by: Julia Lawall Signed-off-by: Jesse Barnes --- diff --git a/drivers/pci/hotplug/fakephp.c b/drivers/pci/hotplug/fakephp.c index 3a2637a0093..b0e7de9e536 100644 --- a/drivers/pci/hotplug/fakephp.c +++ b/drivers/pci/hotplug/fakephp.c @@ -324,6 +324,7 @@ static int disable_slot(struct hotplug_slot *slot) if (test_and_set_bit(0, &dslot->removed)) { dbg("Slot already scheduled for removal\n"); + pci_dev_put(dev); return -ENODEV; }