batman-adv: fix dat NULL pointer dereference
[feed/routing.git] / patches / 0004-batman-adv-Fix-NULL-pointer-dereference-in-DAT-hash-.patch
1 From 9f1fb6914d66e282c2b1f51aa2d4a231c84df84d Mon Sep 17 00:00:00 2001
2 From: Pau Koning <paukoning@gmail.com>
3 Date: Fri, 15 Feb 2013 00:18:56 +0100
4 Subject: [PATCH 4/4] batman-adv: Fix NULL pointer dereference in DAT hash
5 collision avoidance
6
7 An entry in DAT with the hashed position of 0 can cause a NULL pointer
8 dereference when the first entry is checked by batadv_choose_next_candidate.
9 This first candidate automatically has the max value of 0 and the max_orig_node
10 of NULL. Not checking max_orig_node for NULL in batadv_is_orig_node_eligible
11 will lead to a NULL pointer dereference when checking for the lowest address.
12
13 This problem was added in 785ea1144182c341b8b85b0f8180291839d176a8
14 ("batman-adv: Distributed ARP Table - create DHT helper functions").
15
16 Signed-off-by: Pau Koning <paukoning@gmail.com>
17 Signed-off-by: David S. Miller <davem@davemloft.net>
18 Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
19 ---
20 distributed-arp-table.c | 2 +-
21 1 file changed, 1 insertion(+), 1 deletion(-)
22
23 diff --git a/distributed-arp-table.c b/distributed-arp-table.c
24 index ea0bd31..761a590 100644
25 --- a/distributed-arp-table.c
26 +++ b/distributed-arp-table.c
27 @@ -440,7 +440,7 @@ static bool batadv_is_orig_node_eligible(struct batadv_dat_candidate *res,
28 /* this is an hash collision with the temporary selected node. Choose
29 * the one with the lowest address
30 */
31 - if ((tmp_max == max) &&
32 + if ((tmp_max == max) && max_orig_node &&
33 (batadv_compare_eth(candidate->orig, max_orig_node->orig) > 0))
34 goto out;
35
36 --
37 1.7.10.4
38