Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drivers/pnp/resource.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>
Cc: Greg KH <greg@kroah.com>
Cc: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>

authored by

Julia Lawall and committed by
Linus Torvalds
8ea50a3f b64d7082

+3 -1
+3 -1
drivers/pnp/resource.c
··· 367 367 { 368 368 struct pci_dev *pci = NULL; 369 369 for_each_pci_dev(pci) { 370 - if (pci->irq == *irq) 370 + if (pci->irq == *irq) { 371 + pci_dev_put(pci); 371 372 return 0; 373 + } 372 374 } 373 375 } 374 376 #endif