public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/5] drivers/macintosh/via-pmu.c: Add missing pci_dev_put
@ 2007-11-19  8:03 Julia Lawall
  2007-11-19  8:22 ` Benjamin Herrenschmidt
  0 siblings, 1 reply; 2+ messages in thread
From: Julia Lawall @ 2007-11-19  8:03 UTC (permalink / raw)
  To: benh, linux-kernel, kernel-janitors

From: Julia Lawall <julia@diku.dk>

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

In this case, the return under the #else case of #ifdef HACKED_PCI_SAVE
should have a pci_dev_put, just as the return in the case where
HACKED_PCI_SAVE is true does.

This was fixed using the following semantic patch.

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

T *d;
...
while ((d = \(pci_get_device\|pci_get_device_reverse\|pci_get_subsys\|pci_get_class\)(..., d)) != NULL)
  {... when != pci_dev_put(d)
       when != e = d
(
    return d;
|
+  pci_dev_put(d);
?  return ...;
)
...}
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
---

diff -u -p a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
--- a/drivers/macintosh/via-pmu.c	2007-11-18 20:43:10.000000000 +0100
+++ b/drivers/macintosh/via-pmu.c	2007-11-19 08:16:44.000000000 +0100
@@ -1896,8 +1896,10 @@ pbook_pci_restore(void)
  			pci_write_config_dword(pd, i<<4, ps->config[i]);
  		pci_write_config_dword(pd, 4, ps->config[1]);
  #else
-		if (npci-- == 0)
+		if (npci-- == 0) {
+			pci_dev_put(pd);
  			return;
+		}
  		ps++;
  		if (ps->command == 0)
  			continue;

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-11-19  8:22 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-11-19  8:03 [PATCH 2/5] drivers/macintosh/via-pmu.c: Add missing pci_dev_put Julia Lawall
2007-11-19  8:22 ` Benjamin Herrenschmidt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox