]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
PCI: drivers/pci/pci-sysfs.c: Add missing pci_dev_put
authorJulia Lawall <julia@diku.dk>
Tue, 20 Nov 2007 07:41:16 +0000 (08:41 +0100)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 28 Nov 2007 22:35:26 +0000 (14:35 -0800)
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 <julia@diku.dk>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/pci/pci-sysfs.c

index 1b7b2812bf2dd94c3ca9723bd7e2db47209df89a..7d1877341aada287783065bf15ab9f6349b2b07a 100644 (file)
@@ -702,8 +702,10 @@ static int __init pci_sysfs_init(void)
        sysfs_initialized = 1;
        for_each_pci_dev(pdev) {
                retval = pci_create_sysfs_dev_files(pdev);
-               if (retval)
+               if (retval) {
+                       pci_dev_put(pdev);
                        return retval;
+               }
        }
 
        return 0;