public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
* [B.A.T.M.A.N.] [PATCH-maint] batman-adv: fix potential orig_node reference leak
@ 2014-02-08 15:45 Simon Wunderlich
  2014-02-11 12:04 ` Marek Lindner
  2014-02-11 17:26 ` Antonio Quartulli
  0 siblings, 2 replies; 8+ messages in thread
From: Simon Wunderlich @ 2014-02-08 15:45 UTC (permalink / raw)
  To: b.a.t.m.a.n

Since batadv_orig_node_new() sets the refcount to two, assuming that
the calling function will use a reference for putting the orig_node into
a hash or similar, both references must be freed if initialization of
the orig_node fails. Otherwise that object may be leaked in that error
case.

Reported-by: Antonio Quartulli <antonio@meshcoding.com>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
---
 bat_iv_ogm.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/bat_iv_ogm.c b/bat_iv_ogm.c
index 6f4fcdc..6000337 100644
--- a/bat_iv_ogm.c
+++ b/bat_iv_ogm.c
@@ -256,6 +256,8 @@ batadv_iv_ogm_orig_get(struct batadv_priv *bat_priv, const uint8_t *addr)
 free_bcast_own:
 	kfree(orig_node->bat_iv.bcast_own);
 free_orig_node:
+	/* free twice, as batadv_orig_node_new set refcount to 2 */
+	batadv_orig_node_free_ref(orig_node);
 	batadv_orig_node_free_ref(orig_node);
 
 	return NULL;
-- 
1.7.10.4


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

end of thread, other threads:[~2014-02-11 17:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-08 15:45 [B.A.T.M.A.N.] [PATCH-maint] batman-adv: fix potential orig_node reference leak Simon Wunderlich
2014-02-11 12:04 ` Marek Lindner
2014-02-11 17:26 ` Antonio Quartulli
2014-02-11 17:29   ` Martin Hundebøll
2014-02-11 17:34     ` Antonio Quartulli
2014-02-11 17:40       ` Marek Lindner
2014-02-11 17:45         ` Antonio Quartulli
2014-02-11 17:35   ` Simon Wunderlich

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox