Commit f69ae770 authored by Martin Hundebøll's avatar Martin Hundebøll Committed by Antonio Quartulli

batman-adv: Avoid double freeing of bat_counters

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: default avatarMartin Hundebøll <martin@hundeboll.net>
Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
Signed-off-by: default avatarAntonio Quartulli <ordex@autistici.org>
parent 3ccfc1b1
...@@ -181,6 +181,7 @@ void batadv_mesh_free(struct net_device *soft_iface) ...@@ -181,6 +181,7 @@ void batadv_mesh_free(struct net_device *soft_iface)
batadv_originator_free(bat_priv); batadv_originator_free(bat_priv);
free_percpu(bat_priv->bat_counters); free_percpu(bat_priv->bat_counters);
bat_priv->bat_counters = NULL;
atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE); atomic_set(&bat_priv->mesh_state, BATADV_MESH_INACTIVE);
} }
......
...@@ -505,6 +505,7 @@ static int batadv_softif_init_late(struct net_device *dev) ...@@ -505,6 +505,7 @@ static int batadv_softif_init_late(struct net_device *dev)
batadv_debugfs_del_meshif(dev); batadv_debugfs_del_meshif(dev);
free_bat_counters: free_bat_counters:
free_percpu(bat_priv->bat_counters); free_percpu(bat_priv->bat_counters);
bat_priv->bat_counters = NULL;
return ret; return ret;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment