diff options
author | Julia Lawall <julia@diku.dk> | 2008-01-01 22:30:30 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2008-01-04 03:47:02 -0500 |
commit | 76975f8a3186dae501584d0155ea410464f62815 (patch) | |
tree | 265ed11c16755560e27f81a8e7ff2562031cfb58 /net/x25 | |
parent | 304b46996ca1a989fe0fe99831ed38c79e855245 (diff) |
[X25]: Add missing x25_neigh_put
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>
Diffstat (limited to 'net/x25')
-rw-r--r-- | net/x25/x25_forward.c | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/net/x25/x25_forward.c b/net/x25/x25_forward.c index 8738ec7ce693..34478035e05e 100644 --- a/net/x25/x25_forward.c +++ b/net/x25/x25_forward.c | |||
@@ -118,13 +118,14 @@ int x25_forward_data(int lci, struct x25_neigh *from, struct sk_buff *skb) { | |||
118 | goto out; | 118 | goto out; |
119 | 119 | ||
120 | if ( (skbn = pskb_copy(skb, GFP_ATOMIC)) == NULL){ | 120 | if ( (skbn = pskb_copy(skb, GFP_ATOMIC)) == NULL){ |
121 | goto out; | 121 | goto output; |
122 | 122 | ||
123 | } | 123 | } |
124 | x25_transmit_link(skbn, nb); | 124 | x25_transmit_link(skbn, nb); |
125 | 125 | ||
126 | x25_neigh_put(nb); | ||
127 | rc = 1; | 126 | rc = 1; |
127 | output: | ||
128 | x25_neigh_put(nb); | ||
128 | out: | 129 | out: |
129 | return rc; | 130 | return rc; |
130 | } | 131 | } |