Skip to content

Commit

Permalink
batman-adv: fix potential orig_node reference leak
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
  • Loading branch information
Simon Wunderlich authored and Antonio Quartulli committed Feb 17, 2014
1 parent 08bf0ed commit b2262df
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions net/batman-adv/bat_iv_ogm.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,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 sets refcount to 2 */
batadv_orig_node_free_ref(orig_node);
batadv_orig_node_free_ref(orig_node);

return NULL;
Expand Down

0 comments on commit b2262df

Please sign in to comment.