]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
drivers/pcmcia: add missing pci_dev_get
authorJulia Lawall <julia@diku.dk>
Tue, 5 Feb 2008 06:27:46 +0000 (22:27 -0800)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 5 Feb 2008 17:44:09 +0000 (09:44 -0800)
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>
drivers/pcmcia/cardbus.c

index a1bd763b4e336e94b277a6fe650adf2107044807..714baaeb6da1257a264c903b4b36d67570c15486 100644 (file)
@@ -143,7 +143,7 @@ int read_cb_mem(struct pcmcia_socket * s, int space, u_int addr, u_int len, void
        /* Config space? */
        if (space == 0) {
                if (addr + len > 0x100)
-                       goto fail;
+                       goto failput;
                for (; len; addr++, ptr++, len--)
                        pci_read_config_byte(dev, addr, ptr);
                return 0;
@@ -171,6 +171,8 @@ int read_cb_mem(struct pcmcia_socket * s, int space, u_int addr, u_int len, void
        memcpy_fromio(ptr, s->cb_cis_virt + addr, len);
        return 0;
 
+failput:
+       pci_dev_put(dev);
 fail:
        memset(ptr, 0xff, len);
        return -1;