diff options
author | Xiyu Yang <xiyuyang19@fudan.edu.cn> | 2020-04-20 13:37:20 +0800 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2020-05-20 08:15:29 +0200 |
commit | aba0fd6a16ef9a562d22b81f7f3cd365ba9bc0fa (patch) | |
tree | cfd0eb8271bd176bdeee797db402723da1c479dc | |
parent | c62006cf13a7071e40d879097bd280517e05a70e (diff) | |
download | linux-stable-aba0fd6a16ef9a562d22b81f7f3cd365ba9bc0fa.tar.gz linux-stable-aba0fd6a16ef9a562d22b81f7f3cd365ba9bc0fa.tar.bz2 linux-stable-aba0fd6a16ef9a562d22b81f7f3cd365ba9bc0fa.zip |
batman-adv: Fix refcnt leak in batadv_v_ogm_process
commit 6f91a3f7af4186099dd10fa530dd7e0d9c29747d upstream.
batadv_v_ogm_process() invokes batadv_hardif_neigh_get(), which returns
a reference of the neighbor object to "hardif_neigh" with increased
refcount.
When batadv_v_ogm_process() returns, "hardif_neigh" becomes invalid, so
the refcount should be decreased to keep refcount balanced.
The reference counting issue happens in one exception handling paths of
batadv_v_ogm_process(). When batadv_v_ogm_orig_get() fails to get the
orig node and returns NULL, the refcnt increased by
batadv_hardif_neigh_get() is not decreased, causing a refcnt leak.
Fix this issue by jumping to "out" label when batadv_v_ogm_orig_get()
fails to get the orig node.
Fixes: 9323158ef9f4 ("batman-adv: OGMv2 - implement originators logic")
Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r-- | net/batman-adv/bat_v_ogm.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index b0cae59bd327..d2e6885479cb 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -709,7 +709,7 @@ static void batadv_v_ogm_process(const struct sk_buff *skb, int ogm_offset, orig_node = batadv_v_ogm_orig_get(bat_priv, ogm_packet->orig); if (!orig_node) - return; + goto out; neigh_node = batadv_neigh_node_get_or_create(orig_node, if_incoming, ethhdr->h_source); |