Commit 4d5392cc authored by Julia Lawall's avatar Julia Lawall Committed by David S. Miller

drivers/isdn/capi/kcapi.c: Adjust error handling code involving capi_ctr_put

After calling capi_ctr_get, error handling code should call capi_ctr_put.

The semantic match that finds this problem is as follows:
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>
@r@
expression x,E;
statement S;
position p1,p2,p3;
@@

(
if ((x = capi_ctr_get@p1(...)) == NULL || ...) S
|
x = capi_ctr_get@p1(...)
... when != x
if (x == NULL || ...) S
)
<...
if@p3 (...) { ... when != capi_ctr_put(x)
                  when != if (x) { ... capi_ctr_put(x); ...}
    return@p2 ...;
}
...>
(
return x;
|
return 0;
|
x = E
|
E = x
|
capi_ctr_put(x)
)

@exists@
position r.p1,r.p2,r.p3;
expression x;
int ret != 0;
statement S;
@@

* x = capi_ctr_get@p1(...)
  <...
* if@p3 (...)
  S
  ...>
* return@p2 \(NULL\|ret\);
// </smpl>
Signed-off-by: default avatarJulia Lawall <julia@diku.dk>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 2cdc5575
...@@ -828,15 +828,18 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) ...@@ -828,15 +828,18 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data)
return -ESRCH; return -ESRCH;
if (card->load_firmware == NULL) { if (card->load_firmware == NULL) {
printk(KERN_DEBUG "kcapi: load: no load function\n"); printk(KERN_DEBUG "kcapi: load: no load function\n");
capi_ctr_put(card);
return -ESRCH; return -ESRCH;
} }
if (ldef.t4file.len <= 0) { if (ldef.t4file.len <= 0) {
printk(KERN_DEBUG "kcapi: load: invalid parameter: length of t4file is %d ?\n", ldef.t4file.len); printk(KERN_DEBUG "kcapi: load: invalid parameter: length of t4file is %d ?\n", ldef.t4file.len);
capi_ctr_put(card);
return -EINVAL; return -EINVAL;
} }
if (ldef.t4file.data == NULL) { if (ldef.t4file.data == NULL) {
printk(KERN_DEBUG "kcapi: load: invalid parameter: dataptr is 0\n"); printk(KERN_DEBUG "kcapi: load: invalid parameter: dataptr is 0\n");
capi_ctr_put(card);
return -EINVAL; return -EINVAL;
} }
...@@ -849,6 +852,7 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data) ...@@ -849,6 +852,7 @@ static int old_capi_manufacturer(unsigned int cmd, void __user *data)
if (card->cardstate != CARD_DETECTED) { if (card->cardstate != CARD_DETECTED) {
printk(KERN_INFO "kcapi: load: contr=%d not in detect state\n", ldef.contr); printk(KERN_INFO "kcapi: load: contr=%d not in detect state\n", ldef.contr);
capi_ctr_put(card);
return -EBUSY; return -EBUSY;
} }
card->cardstate = CARD_LOADING; card->cardstate = CARD_LOADING;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment