Skip to content

Commit

Permalink
batman-adv: Avoid double freeing of bat_counters
Browse files Browse the repository at this point in the history
On errors in batadv_mesh_init(), bat_counters will be freed in both
batadv_mesh_free() and batadv_softif_init_late(). This patch fixes this
by returning earlier from batadv_softif_init_late() in case of errors in
batadv_mesh_init() and by setting bat_counters to NULL after freeing.

Signed-off-by: Martin Hundebøll <martin@hundeboll.net>
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
  • Loading branch information
Martin Hundebøll authored and Antonio Quartulli committed May 21, 2013
1 parent 3ccfc1b commit f69ae77
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 0 deletions.
1 change: 1 addition & 0 deletions net/batman-adv/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ void batadv_mesh_free(struct net_device *soft_iface)
batadv_originator_free(bat_priv);

free_percpu(bat_priv->bat_counters);
bat_priv->bat_counters = NULL;

atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
}
Expand Down
1 change: 1 addition & 0 deletions net/batman-adv/soft-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -505,6 +505,7 @@ static int batadv_softif_init_late(struct net_device *dev)
batadv_debugfs_del_meshif(dev);
free_bat_counters:
free_percpu(bat_priv->bat_counters);
bat_priv->bat_counters = NULL;

return ret;
}
Expand Down

0 comments on commit f69ae77

Please sign in to comment.