Skip to content

Commit 923b981

Browse files
sherllygregkh
authored andcommitted
net/x25: Fix x25_neigh refcnt leak when x25 disconnect
commit 4becb7e upstream. 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 <[email protected]> Signed-off-by: Xin Tan <[email protected]> Signed-off-by: David S. Miller <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent fd9534f commit 923b981

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/x25/x25_subr.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,10 @@ void x25_disconnect(struct sock *sk, int reason, unsigned char cause,
363363
x25->neighbour = NULL;
364364
read_unlock_bh(&x25_list_lock);
365365
}
366+
read_lock_bh(&x25_list_lock);
367+
x25_neigh_put(x25->neighbour);
368+
x25->neighbour = NULL;
369+
read_unlock_bh(&x25_list_lock);
366370
}
367371

368372
/*

0 commit comments

Comments
 (0)