diff options
author | Julia Lawall <julia@diku.dk> | 2008-02-05 01:27:46 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@woody.linux-foundation.org> | 2008-02-05 12:44:09 -0500 |
commit | 1523508d6321436b6edfcd99aab04a344f9aed3f (patch) | |
tree | c97c1015c51f4e3576d14313d350c545869e6913 /drivers/pcmcia | |
parent | 5a1c3e1aa977457ded6fd0739e032c9684bf23bd (diff) |
drivers/pcmcia: add missing pci_dev_get
pci_get_slot does a pci_dev_get, so pci_dev_put needs to be called in an
error case.
An extract of the semantic match used to find the problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)
// <smpl>
@@
type find1.T,T1,T2;
identifier find1.E;
statement find1.S;
expression x1,x2,x3;
expression find1.test;
int ret != 0;
@@
T E;
...
(
* E = pci_get_slot(...);
if (E == NULL) S
|
* if ((E = pci_get_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 (test) {
... when != pci_dev_put(...,(T2)E,...)
when != if (E != NULL) { ... pci_dev_put(...,(T2)E,...); ...}
when != x2 = (T2)E
(
* return;
|
* return ret;
)
}
// </smpl>
Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/pcmcia')
-rw-r--r-- | drivers/pcmcia/cardbus.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/pcmcia/cardbus.c b/drivers/pcmcia/cardbus.c index a1bd763b4e33..714baaeb6da1 100644 --- a/drivers/pcmcia/cardbus.c +++ b/drivers/pcmcia/cardbus.c | |||
@@ -143,7 +143,7 @@ int read_cb_mem(struct pcmcia_socket * s, int space, u_int addr, u_int len, void | |||
143 | /* Config space? */ | 143 | /* Config space? */ |
144 | if (space == 0) { | 144 | if (space == 0) { |
145 | if (addr + len > 0x100) | 145 | if (addr + len > 0x100) |
146 | goto fail; | 146 | goto failput; |
147 | for (; len; addr++, ptr++, len--) | 147 | for (; len; addr++, ptr++, len--) |
148 | pci_read_config_byte(dev, addr, ptr); | 148 | pci_read_config_byte(dev, addr, ptr); |
149 | return 0; | 149 | return 0; |
@@ -171,6 +171,8 @@ int read_cb_mem(struct pcmcia_socket * s, int space, u_int addr, u_int len, void | |||
171 | memcpy_fromio(ptr, s->cb_cis_virt + addr, len); | 171 | memcpy_fromio(ptr, s->cb_cis_virt + addr, len); |
172 | return 0; | 172 | return 0; |
173 | 173 | ||
174 | failput: | ||
175 | pci_dev_put(dev); | ||
174 | fail: | 176 | fail: |
175 | memset(ptr, 0xff, len); | 177 | memset(ptr, 0xff, len); |
176 | return -1; | 178 | return -1; |