]> rtime.felk.cvut.cz Git - lisovros/linux_canprio.git/commitdiff
[X25]: Add missing x25_neigh_put
authorJulia Lawall <julia@diku.dk>
Wed, 2 Jan 2008 03:30:30 +0000 (19:30 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 4 Jan 2008 08:47:02 +0000 (00:47 -0800)
The function x25_get_neigh increments a reference count.  At the point of
the second goto out, the result of calling x25_get_neigh is only stored in
a local variable, and thus no one outside the function will be able to
decrease the reference count.  Thus, x25_neigh_put should be called before
the return in this case.

The problem was found using the following semantic match.
(http://www.emn.fr/x-info/coccinelle/)

// <smpl>

@@
type T,T1,T2;
identifier E;
statement S;
expression x1,x2,x3;
int ret;
@@

  T E;
  ...
* if ((E = x25_get_neigh(...)) == NULL)
  S
  ... when != x25_neigh_put(...,(T1)E,...)
      when != if (E != NULL) { ... x25_neigh_put(...,(T1)E,...); ...}
      when != x1 = (T1)E
      when != E = x3;
      when any
  if (...) {
    ... when != x25_neigh_put(...,(T2)E,...)
        when != if (E != NULL) { ... x25_neigh_put(...,(T2)E,...); ...}
        when != x2 = (T2)E
(
*   return;
|
*   return ret;
)
  }
// </smpl>

Signed-off-by: Julia Lawall <julia@diku.dk>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/x25/x25_forward.c

index 8738ec7ce69336dd1960d9e3c8c9a0e1fa68a0e4..34478035e05edd64131525b438eab2bedc55791c 100644 (file)
@@ -118,13 +118,14 @@ int x25_forward_data(int lci, struct x25_neigh *from, struct sk_buff *skb) {
                goto out;
 
        if ( (skbn = pskb_copy(skb, GFP_ATOMIC)) == NULL){
-               goto out;
+               goto output;
 
        }
        x25_transmit_link(skbn, nb);
 
-       x25_neigh_put(nb);
        rc = 1;
+output:
+       x25_neigh_put(nb);
 out:
        return rc;
 }