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

* Re: [PATCH 2/5] drivers/macintosh/via-pmu.c: Add missing pci_dev_put
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Benjamin Herrenschmidt @ 2007-11-19  8:22 UTC (permalink / raw)
  To: Julia Lawall; +Cc: linux-kernel, kernel-janitors


On Mon, 2007-11-19 at 09:03 +0100, Julia Lawall wrote:
> 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.

I think most of that code is no longer necessary (and the lack of
pci_dev_put() is mostly due to the fact that this code long predates the
existence of pci_dev_put :-)

I want to try out without that PCI save/restore code on a couple of old
machines see if we can just remove the whole thing.

Ben.



^ 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