From: Julia Lawall <[EMAIL PROTECTED]>

There should be a pci_dev_put when breaking out of a loop that iterates
over calls to pci_get_device and similar functions.

This was fixed using the following semantic patch.

// <smpl>
@@
identifier d;
type T;
expression e;
iterator for_each_pci_dev;
@@

T *d;
...
for_each_pci_dev(d)
  {... when != pci_dev_put(d)
       when != e = d
(
   return d;
|
+  pci_dev_put(d);
?  return ...;
)
...}
// </smpl>

Signed-off-by: Julia Lawall <[EMAIL PROTECTED]>
---

diff -u -p a/drivers/pnp/resource.c b/drivers/pnp/resource.c
--- a/drivers/pnp/resource.c    2007-10-22 11:25:20.000000000 +0200
+++ b/drivers/pnp/resource.c    2007-11-19 08:18:44.000000000 +0100
@@ -367,8 +367,10 @@ int pnp_check_irq(struct pnp_dev *dev, i
        {
                struct pci_dev *pci = NULL;
                for_each_pci_dev(pci) {
-                       if (pci->irq == *irq)
+                       if (pci->irq == *irq) {
+                               pci_dev_put(pci);
                                return 0;
+                       }
                }
        }
 #endif
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to