Merge pull request #624 from ecsv/batadv-for-18.06
[feed/routing.git] / batman-adv / patches / 0045-batman-adv-Fix-refcnt-leak-in-batadv_v_ogm_process.patch
1 From: Xiyu Yang <xiyuyang19@fudan.edu.cn>
2 Date: Mon, 20 Apr 2020 13:37:20 +0800
3 Subject: batman-adv: Fix refcnt leak in batadv_v_ogm_process
4
5 batadv_v_ogm_process() invokes batadv_hardif_neigh_get(), which returns
6 a reference of the neighbor object to "hardif_neigh" with increased
7 refcount.
8
9 When batadv_v_ogm_process() returns, "hardif_neigh" becomes invalid, so
10 the refcount should be decreased to keep refcount balanced.
11
12 The reference counting issue happens in one exception handling paths of
13 batadv_v_ogm_process(). When batadv_v_ogm_orig_get() fails to get the
14 orig node and returns NULL, the refcnt increased by
15 batadv_hardif_neigh_get() is not decreased, causing a refcnt leak.
16
17 Fix this issue by jumping to "out" label when batadv_v_ogm_orig_get()
18 fails to get the orig node.
19
20 Fixes: 667996ebeab4 ("batman-adv: OGMv2 - implement originators logic")
21 Signed-off-by: Xiyu Yang <xiyuyang19@fudan.edu.cn>
22 Signed-off-by: Xin Tan <tanxin.ctf@gmail.com>
23 Signed-off-by: Sven Eckelmann <sven@narfation.org>
24
25 Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/4515f5e6a4ccbe1c563b05f2d487eb9eef3c9740
26
27 diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c
28 index bf9ea404abe7cbe1dd2113881856cd35b718b7d1..0458de53cb64b2da51de492ffa27f33068351cc8 100644
29 --- a/net/batman-adv/bat_v_ogm.c
30 +++ b/net/batman-adv/bat_v_ogm.c
31 @@ -735,7 +735,7 @@ static void batadv_v_ogm_process(const struct sk_buff *skb, int ogm_offset,
32
33 orig_node = batadv_v_ogm_orig_get(bat_priv, ogm_packet->orig);
34 if (!orig_node)
35 - return;
36 + goto out;
37
38 neigh_node = batadv_neigh_node_get_or_create(orig_node, if_incoming,
39 ethhdr->h_source);