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 mar...@hundeboll.net
---
v2:
Removed label as suggested by Antonio
v3:
Set bat_counters to NULL after freeing
main.c | 1 +
soft-interface.c | 9 -
2 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/main.c b/main.c
index 3e30a0f..aae96ca 100644
--- a/main.c
+++ b/main.c
@@ -173,6 +173,7 @@ void batadv_mesh_free(struct net_device *soft_iface)
batadv_dat_free(bat_priv);
free_percpu(bat_priv-bat_counters);
+ bat_priv-bat_counters = NULL;
atomic_set(bat_priv-mesh_state, BATADV_MESH_INACTIVE);
}
diff --git a/soft-interface.c b/soft-interface.c
index c2a9c20..6946caa 100644
--- a/soft-interface.c
+++ b/soft-interface.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
+#/* Copyright (C) 2007-2013 B.A.T.M.A.N. contributors:
*
* Marek Lindner, Simon Wunderlich
*
@@ -497,14 +497,13 @@ static int batadv_softif_init_late(struct net_device *dev)
ret = batadv_mesh_init(dev);
if (ret 0)
- goto unreg_debugfs;
+ batadv_debugfs_del_meshif(dev);
- return 0;
+ return ret;
-unreg_debugfs:
- batadv_debugfs_del_meshif(dev);
free_bat_counters:
free_percpu(bat_priv-bat_counters);
+ bat_priv-bat_counters = NULL;
return ret;
}
--
1.8.2.1