Skip to contentSkip to conversation

batman-adv: release vlan object after checking the CRC

PATCH Applied Antonio Quartulli 2 participants 2 messages Jan 28, 2014 – Jan 29, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 batman-adv: release vlan object after checking the CRC

There is a refcounter unbalance in the CRC checking routine invoked on OGM reception. A vlan object is retrieved (thus its refcounter is increased by one) but it is never properly released. This leads to a memleak because the vlan object will never be free'd.

Fix this by releasing the vlan object after having read the CRC.

---
 translation-table.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
translation-table.c +5 -1
index 3fca99d..097ca01 100644
@@ -2248,6 +2248,7 @@ static bool batadv_tt_global_check_crc(struct batadv_orig_node *orig_node,
 {
 	struct batadv_tvlv_tt_vlan_data *tt_vlan_tmp;
 	struct batadv_orig_node_vlan *vlan;
+	uint32_t crc;
 	int i;
 
 	/* check if each received CRC matches the locally stored one */
@@ -2267,7 +2268,10 @@ static bool batadv_tt_global_check_crc(struct batadv_orig_node *orig_node,
 		if (!vlan)
 			return false;
 
-		if (vlan->tt.crc != ntohl(tt_vlan_tmp->crc))
+		crc = vlan->tt.crc;
+		batadv_orig_node_vlan_free_ref(vlan);
+
+		if (crc != ntohl(tt_vlan_tmp->crc))
 			return false;
 	}
 
Signature · 1 line
1.8.5.3
#1 lore raw
Quoted 9 lines · On Tuesday 28 January 2014 02:06:47 Antonio Quartulli wrote:

There is a refcounter unbalance in the CRC checking routine invoked on OGM reception. A vlan object is retrieved (thus its refcounter is increased by one) but it is never properly released. This leads to a memleak because the vlan object will never be free'd.

Fix this by releasing the vlan object after having read the CRC.

Quoted 7 lines
---
 translation-table.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Applied in revision dc08c04.

Thanks,
Marek