[PATCH] batman-adv: Fix mem leak in the batadv_tt_local_event() function

Subsystems: batman advanced, the rest

STALE5137d

4 messages, 3 authors, 2012-08-08 · open the first message on its own page

[PATCH] batman-adv: Fix mem leak in the batadv_tt_local_event() function

From: Jesper Juhl <hidden>
Date: 2012-08-07 18:32:36

Memory is allocated for 'tt_change_node' with kmalloc().
'tt_change_node' may go out of scope really being used for anything
(except have a few members initialized) if we hit the 'del:' label.
This patch makes sure we free the memory in that case.

Signed-off-by: Jesper Juhl <redacted>
---
 net/batman-adv/translation-table.c | 1 +
 1 file changed, 1 insertion(+)

 Compile tested only.
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index a438f4b..99dd8f7 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -197,6 +197,7 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv,
 del:
 		list_del(&entry->list);
 		kfree(entry);
+		kfree(tt_change_node);
 		event_removed = true;
 		goto unlock;
 	}
-- 
1.7.11.4


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

Re: [PATCH] batman-adv: Fix mem leak in the batadv_tt_local_event() function

From: Jesper Juhl <hidden>
Date: 2012-08-07 18:38:52

On Tue, 7 Aug 2012, Jesper Juhl wrote:
Memory is allocated for 'tt_change_node' with kmalloc().
'tt_change_node' may go out of scope really being used for anything
This should of course read "... go out of scope without really being used ..." .
quoted hunk
(except have a few members initialized) if we hit the 'del:' label.
This patch makes sure we free the memory in that case.

Signed-off-by: Jesper Juhl <redacted>
---
 net/batman-adv/translation-table.c | 1 +
 1 file changed, 1 insertion(+)

 Compile tested only.
diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c
index a438f4b..99dd8f7 100644
--- a/net/batman-adv/translation-table.c
+++ b/net/batman-adv/translation-table.c
@@ -197,6 +197,7 @@ static void batadv_tt_local_event(struct batadv_priv *bat_priv,
 del:
 		list_del(&entry->list);
 		kfree(entry);
+		kfree(tt_change_node);
 		event_removed = true;
 		goto unlock;
 	}
-- 
Jesper Juhl [off-list ref]       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.

Re: [PATCH] batman-adv: Fix mem leak in the batadv_tt_local_event() function

From: Antonio Quartulli <hidden>
Date: 2012-08-07 18:50:45

On Tue, Aug 07, 2012 at 08:32:34PM +0200, Jesper Juhl wrote:
Memory is allocated for 'tt_change_node' with kmalloc().
'tt_change_node' may go out of scope really being used for anything
(except have a few members initialized) if we hit the 'del:' label.
This patch makes sure we free the memory in that case.

Signed-off-by: Jesper Juhl <redacted>
Acked-by: Antonio Quartulli <redacted>


Thank you very much Jepser!


-- 
Antonio Quartulli

..each of us alone is worth nothing..
Ernesto "Che" Guevara

Re: [PATCH] batman-adv: Fix mem leak in the batadv_tt_local_event() function

From: David Miller <davem@davemloft.net>
Date: 2012-08-08 23:04:30

From: Antonio Quartulli <redacted>
Date: Tue, 7 Aug 2012 20:50:36 +0200
On Tue, Aug 07, 2012 at 08:32:34PM +0200, Jesper Juhl wrote:
quoted
Memory is allocated for 'tt_change_node' with kmalloc().
'tt_change_node' may go out of scope really being used for anything
(except have a few members initialized) if we hit the 'del:' label.
This patch makes sure we free the memory in that case.

Signed-off-by: Jesper Juhl <redacted>
Acked-by: Antonio Quartulli <redacted>
Applied, thanks.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help