1
0
Fork 0

PCI: drivers/pci/pci-sysfs.c: Add missing pci_dev_put

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>
hifive-unleashed-5.1
Julia Lawall 2007-11-20 08:41:16 +01:00 committed by Greg Kroah-Hartman
parent bf164410d0
commit 151fc5dfc8
1 changed files with 3 additions and 1 deletions

View 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;