]> git.ipfire.org Git - people/arne_f/kernel.git/commit
X25: Add missing x25_neigh_put
authorJulia Lawall <julia@diku.dk>
Fri, 11 Jan 2008 09:26:33 +0000 (01:26 -0800)
committerGreg Kroah-Hartman <gregkh@suse.de>
Wed, 6 Feb 2008 19:43:40 +0000 (11:43 -0800)
commita871dae86feab2232a297b649086ea46af60c7ac
tree5aff4344045a2ee0f2839b302df53c7d50693fd8
parent33593eb711ae47e81ef0aab298e231c7a35f19f4
X25: Add missing x25_neigh_put

[X25]: Add missing x25_neigh_put

[ Upstream commit: 76975f8a3186dae501584d0155ea410464f62815 ]

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>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
net/x25/x25_forward.c