batman-adv: Avoid double freeing of bat_counters
authorMartin Hundebøll <martin@hundeboll.net>
Wed, 17 Apr 2013 19:13:16 +0000 (21:13 +0200)
committerAntonio Quartulli <ordex@autistici.org>
Tue, 21 May 2013 19:34:36 +0000 (21:34 +0200)
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>
net/batman-adv/main.c
net/batman-adv/soft-interface.c

index 1240f07ad31dc631c5dc941f31bfd541f0205fea..51aafd669cbbd6a7714f9ab075f647313c8234d5 100644 (file)
@@ -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);
 }
index 6f20d339e33adb3bab929d9bc406f3c8cebd959a..819dfb006cdfafbcd3c63d12c5f7e76c0588ed43 100644 (file)
@@ -505,6 +505,7 @@ unreg_debugfs:
        batadv_debugfs_del_meshif(dev);
 free_bat_counters:
        free_percpu(bat_priv->bat_counters);
+       bat_priv->bat_counters = NULL;
 
        return ret;
 }