b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH maint] batman-adv: release vlan object after checking the CRC
@ 2014-01-28  1:06 Antonio Quartulli
  2014-01-29  4:45 ` Marek Lindner
  0 siblings, 1 reply; 4+ messages in thread
From: Antonio Quartulli @ 2014-01-28  1:06 UTC (permalink / raw)
  To: b.a.t.m.a.n; +Cc: Antonio Quartulli

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.

Reported-by: Russell Senior <russell@personaltelco.net>
Reported-by: Daniel <daniel@makrotopia.org>
Reported-by: cmsv <cmsv@wirelesspt.net>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
---
 translation-table.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/translation-table.c b/translation-table.c
index 3fca99d..097ca01 100644
--- a/translation-table.c
+++ b/translation-table.c
@@ -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;
 	}
 
-- 
1.8.5.3


^ permalink raw reply related	[flat|nested] 4+ messages in thread
* Re: [B.A.T.M.A.N.] batman-adv: memory leak?
@ 2014-01-26 14:21 Antonio Quartulli
  2014-01-26 14:24 ` [B.A.T.M.A.N.] [PATCH maint] batman-adv: release vlan object after checking the CRC Antonio Quartulli
  0 siblings, 1 reply; 4+ messages in thread
From: Antonio Quartulli @ 2014-01-26 14:21 UTC (permalink / raw)
  To: b.a.t.m.a.n

[-- Attachment #1: Type: text/plain, Size: 1102 bytes --]

On 26/01/14 13:57, Daniel wrote:
> I now built OpenWrt trunk/BB r39365 with batman-adv 2013.4.0 instead of
> 2014.0.0, tried with all possible settings, no memory leak what-so-over, happy
> uptimes of more than a day by now :)
> all other system components and settings are exactly identical to my previous
> setup with batman-adv 2014.0.0.
> 
> On 01/23/2014 04:35 AM, Daniel wrote:
>> On 01/23/2014 01:10 AM, cmsv wrote:
>>> what version are you using ?
> 
>> out-of-memory every 20 minutes or so on OpenWrt trunk/BB r39365 on tl-wr841nd-v8
>> with batman-adv 2014.0.0 from openwrt's routing feed with "batman-adv: fix
>> batman-adv header overhead calculation" and "batman-adv: fix soft-interface MTU
>> computation" on top.
>> A sample node is (occasionally) reachable via DN42 at 104.61.99.104 (feel free
>> to ask for ssh or any kind of logs, serial access, remote gdb or whatever)
> 

Thanks for testing guys!

I found something wrong in the code and I am going to send a patch soon.
I'd really appreciate if somebody could test it!

Thanks!

-- 
Antonio Quartulli


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-01-29  4:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-01-28  1:06 [B.A.T.M.A.N.] [PATCH maint] batman-adv: release vlan object after checking the CRC Antonio Quartulli
2014-01-29  4:45 ` Marek Lindner
  -- strict thread matches above, loose matches on Subject: below --
2014-01-26 14:21 [B.A.T.M.A.N.] batman-adv: memory leak? Antonio Quartulli
2014-01-26 14:24 ` [B.A.T.M.A.N.] [PATCH maint] batman-adv: release vlan object after checking the CRC Antonio Quartulli
2014-01-27 18:43   ` Russell Senior

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).