[<prev] [next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.58.0801041545020.1184@pc-041.diku.dk>
Date: Fri, 4 Jan 2008 15:45:33 +0100 (MET)
From: Julia Lawall <julia@...u.dk>
To: benh@...nel.crashing.org, linux-kernel@...r.kernel.org,
kernel-janitors@...r.kernel.org
Subject: [PATCH] drivers/macintosh: Add missing pci_dev_get
From: Julia Lawall <julia@...u.dk>
pci_get_bus_and_slot does a pci_dev_get, so pci_dev_put needs to be called
in an error case.
The problem was fixed using the following semantic patch.
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@exists@
type T1,T2;
identifier E;
statement S,S1;
expression x1,x2,x3;
expression test;
int ret != 0;
@@
struct pci_dev *E;
...
(
E = \(pci_get_slot\|pci_get_device\|pci_get_bus_and_slot\)(...);
if (E == NULL) S
|
if ((E = \(pci_get_slot\|pci_get_device\|pci_get_bus_and_slot\)(...)) == NULL) S
)
... when != pci_dev_put(...,(T1)E,...)
when != if (E != NULL) { ... pci_dev_put(...,(T1)E,...); ...}
when != x1 = (T1)E
when != E = x3;
when any
(
if (E == NULL) S1
|
if (test)
+ {
(
+ pci_dev_put(E);
return;
|
+ pci_dev_put(E);
return ret;
)
+ }
|
if (test) {
... when != pci_dev_put(...,(T2)E,...)
when != if (E != NULL) { ... pci_dev_put(...,(T2)E,...); ...}
when != x2 = (T2)E
(
+ pci_dev_put(E);
return;
|
+ pci_dev_put(E);
return ret;
)
}
)
// </smpl>
Signed-off-by: Julia Lawall <julia@...u.dk>
---
diff -u -p a/drivers/macintosh/via-pmu.c b/drivers/macintosh/via-pmu.c
--- a/drivers/macintosh/via-pmu.c 2007-12-21 06:57:19.000000000 +0100
+++ b/drivers/macintosh/via-pmu.c 2008-01-04 14:00:03.000000000 +0100
@@ -2142,6 +2142,7 @@ static int powerbook_sleep_grackle(void)
ret = pmac_suspend_devices();
if (ret) {
printk(KERN_ERR "Sleep rejected by devices\n");
+ pci_dev_put(grackle);
return ret;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists