diff options
author | Xiyu Yang <xiyuyang19@fudan.edu.cn> | 2020-04-15 16:36:19 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-05-02 17:20:33 +0200 |
commit | 5b5407dc7937f9acda662102bd5183e44c8906bd (patch) | |
tree | 528549e810969b73444edee2abc461ebcfea7655 /net/netrom | |
parent | 6ec73a87c216ba78fad9bf775b54460961519664 (diff) | |
download | linux-stable-5b5407dc7937f9acda662102bd5183e44c8906bd.tar.gz linux-stable-5b5407dc7937f9acda662102bd5183e44c8906bd.tar.bz2 linux-stable-5b5407dc7937f9acda662102bd5183e44c8906bd.zip |
net: netrom: Fix potential nr_neigh refcnt leak in nr_add_node
[ Upstream commit d03f228470a8c0a22b774d1f8d47071e0de4f6dd ]
nr_add_node() invokes nr_neigh_get_dev(), which returns a local
reference of the nr_neigh object to "nr_neigh" with increased refcnt.
When nr_add_node() returns, "nr_neigh" becomes invalid, so the refcount
should be decreased to keep refcount balanced.
The issue happens in one normal path of nr_add_node(), which forgets to
decrease the refcnt increased by nr_neigh_get_dev() and causes a refcnt
leak. It should decrease the refcnt before the function returns like
other normal paths do.
Fix this issue by calling nr_neigh_put() before the nr_add_node()
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>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net/netrom')
-rw-r--r-- | net/netrom/nr_route.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/net/netrom/nr_route.c b/net/netrom/nr_route.c index d72a4f1558f2..ef6a3d586591 100644 --- a/net/netrom/nr_route.c +++ b/net/netrom/nr_route.c @@ -199,6 +199,7 @@ static int __must_check nr_add_node(ax25_address *nr, const char *mnemonic, /* refcount initialized at 1 */ spin_unlock_bh(&nr_node_list_lock); + nr_neigh_put(nr_neigh); return 0; } nr_node_lock(nr_node); |