]> git.baikalelectronics.ru Git - kernel.git/commit
net/x25: Fix x25_neigh refcnt leak when x25 disconnect
authorXiyu Yang <xiyuyang19@fudan.edu.cn>
Sat, 25 Apr 2020 13:06:25 +0000 (21:06 +0800)
committerDavid S. Miller <davem@davemloft.net>
Mon, 27 Apr 2020 18:20:30 +0000 (11:20 -0700)
commita9d7dc6b281f1c3e4045be1dec9731b76150e34b
tree4787f195bcdbb76ec58114be47c1cf90107f81e6
parentc23c9971cff1bf504d2f561c305db7b0c020f70d
net/x25: Fix x25_neigh refcnt leak when x25 disconnect

x25_connect() invokes x25_get_neigh(), which returns a reference of the
specified x25_neigh object to "x25->neighbour" with increased refcnt.

When x25 connect success and returns, the reference still be hold by
"x25->neighbour", so the refcount should be decreased in
x25_disconnect() to keep refcount balanced.

The reference counting issue happens in x25_disconnect(), which forgets
to decrease the refcnt increased by x25_get_neigh() in x25_connect(),
causing a refcnt leak.

Fix this issue by calling x25_neigh_put() before x25_disconnect()
returns.

Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/x25/x25_subr.c