batman-adv: 2014.0.0 updated stability fixes
[feed/routing.git] / batman-adv / patches / 0005-batman-adv-release-vlan-object-after-checking-the-CR.patch
1 From dc08c045b46bdd9a5c81068a89f9f2a78d3d4bbd Mon Sep 17 00:00:00 2001
2 From: Antonio Quartulli <antonio@meshcoding.com>
3 Date: Tue, 28 Jan 2014 02:06:47 +0100
4 Subject: [PATCH 5/5] batman-adv: release vlan object after checking the CRC
5
6 There is a refcounter unbalance in the CRC checking routine
7 invoked on OGM reception. A vlan object is retrieved (thus
8 its refcounter is increased by one) but it is never properly
9 released. This leads to a memleak because the vlan object
10 will never be free'd.
11
12 Fix this by releasing the vlan object after having read the
13 CRC.
14
15 Reported-by: Russell Senior <russell@personaltelco.net>
16 Reported-by: Daniel <daniel@makrotopia.org>
17 Reported-by: cmsv <cmsv@wirelesspt.net>
18 Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
19 Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
20 ---
21 translation-table.c | 6 +++++-
22 1 file changed, 5 insertions(+), 1 deletion(-)
23
24 diff --git a/translation-table.c b/translation-table.c
25 index 45b6155..05c2a9b 100644
26 --- a/translation-table.c
27 +++ b/translation-table.c
28 @@ -2248,6 +2248,7 @@ static bool batadv_tt_global_check_crc(struct batadv_orig_node *orig_node,
29 {
30 struct batadv_tvlv_tt_vlan_data *tt_vlan_tmp;
31 struct batadv_orig_node_vlan *vlan;
32 + uint32_t crc;
33 int i;
34
35 /* check if each received CRC matches the locally stored one */
36 @@ -2267,7 +2268,10 @@ static bool batadv_tt_global_check_crc(struct batadv_orig_node *orig_node,
37 if (!vlan)
38 return false;
39
40 - if (vlan->tt.crc != ntohl(tt_vlan_tmp->crc))
41 + crc = vlan->tt.crc;
42 + batadv_orig_node_vlan_free_ref(vlan);
43 +
44 + if (crc != ntohl(tt_vlan_tmp->crc))
45 return false;
46 }
47
48 --
49 1.8.5.3
50