Merge pull request #150 from booo/olsrd2_hotplug_fix
[feed/routing.git] / batman-adv / patches / 0003-batman-adv-Avoid-nullptr-derefence-in-batadv_v_neigh.patch
1 From 036aa7b7181ee96ae6971eb31dd97b6ace7c0a80 Mon Sep 17 00:00:00 2001
2 From: Sven Eckelmann <sven@narfation.org>
3 Date: Fri, 6 May 2016 11:43:38 +0200
4 Subject: [PATCH 3/6] batman-adv: Avoid nullptr derefence in
5 batadv_v_neigh_is_sob
6
7 batadv_neigh_ifinfo_get can return NULL when it cannot find (even when only
8 temporarily) anymore the neigh_ifinfo in the list neigh->ifinfo_list. This
9 has to be checked to avoid kernel Oopses when the ifinfo is dereferenced.
10
11 This a situation which isn't expected but is already handled by functions
12 like batadv_v_neigh_cmp. The same kind of warning is therefore used before
13 the function returns without dereferencing the pointers.
14
15 Fixes: b05bbab5e1fc ("batman-adv: B.A.T.M.A.N. V - implement neighbor comparison API calls")
16 Signed-off-by: Sven Eckelmann <sven@narfation.org>
17 Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
18 ---
19 net/batman-adv/bat_v.c | 3 +++
20 1 file changed, 3 insertions(+)
21
22 diff --git a/net/batman-adv/bat_v.c b/net/batman-adv/bat_v.c
23 index 4547fce..7e1467a 100644
24 --- a/net/batman-adv/bat_v.c
25 +++ b/net/batman-adv/bat_v.c
26 @@ -295,6 +295,9 @@ static bool batadv_v_neigh_is_sob(struct batadv_neigh_node *neigh1,
27 ifinfo1 = batadv_neigh_ifinfo_get(neigh1, if_outgoing1);
28 ifinfo2 = batadv_neigh_ifinfo_get(neigh2, if_outgoing2);
29
30 + if (WARN_ON(!ifinfo1 || !ifinfo2))
31 + return false;
32 +
33 threshold = ifinfo1->bat_v.throughput / 4;
34 threshold = ifinfo1->bat_v.throughput - threshold;
35
36 --
37 2.8.0.rc3
38