37a672f3acbdcccb9bd82dba1b4f016d9f44cd1c
[feed/routing.git] / batman-adv / patches / 0007-batman-adv-Fix-bat_v-best-gw-refcnt-after-netlink-du.patch
1 From: Sven Eckelmann <sven@narfation.org>
2 Date: Sat, 2 Jun 2018 17:26:35 +0200
3 Subject: [PATCH] batman-adv: Fix bat_v best gw refcnt after netlink dump
4
5 A reference for the best gateway is taken when the list of gateways in the
6 mesh is sent via netlink. This is necessary to check whether the currently
7 dumped entry is the currently selected gateway or not. This information is
8 then transferred as flag BATADV_ATTR_FLAG_BEST.
9
10 After the comparison of the current entry is done,
11 batadv_v_gw_dump_entry() has to decrease the reference counter again.
12 Otherwise the reference will be held and thus prevents a proper shutdown of
13 the batman-adv interfaces (and some of the interfaces enslaved in it).
14
15 Fixes: 15315a94ad98 ("batman-adv: add B.A.T.M.A.N. V bat_gw_dump implementations")
16 Signed-off-by: Sven Eckelmann <sven@narfation.org>
17 Acked-by: Marek Lindner <mareklindner@neomailbox.ch>
18
19 Origin: upstream, https://git.open-mesh.org/batman-adv.git/commit/2b422b5808183d1084b450b89d9a085a13dd6d2c
20 ---
21 net/batman-adv/bat_v.c | 4 +++-
22 1 file changed, 3 insertions(+), 1 deletion(-)
23
24 diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
25 index ec93337ee2597738e46b87dd72724d5becf3f48e..6baec4e68898c6e992e7522d2ee8c78ce62a1b08 100644
26 --- a/net/batman-adv/bat_v.c
27 +++ b/net/batman-adv/bat_v.c
28 @@ -927,7 +927,7 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
29 {
30 struct batadv_neigh_ifinfo *router_ifinfo = NULL;
31 struct batadv_neigh_node *router;
32 - struct batadv_gw_node *curr_gw;
33 + struct batadv_gw_node *curr_gw = NULL;
34 int ret = 0;
35 void *hdr;
36
37 @@ -995,6 +995,8 @@ static int batadv_v_gw_dump_entry(struct sk_buff *msg, u32 portid, u32 seq,
38 ret = 0;
39
40 out:
41 + if (curr_gw)
42 + batadv_gw_node_put(curr_gw);
43 if (router_ifinfo)
44 batadv_neigh_ifinfo_put(router_ifinfo);
45 if (router)