Merge branch 'master' of github.com:openwrt-routing/packages
[feed/routing.git] / batman-adv / patches / 0006-batman-adv-reorder-clean-up-routine-in-order-to-avoi.patch
1 From 763f413b9c74ccb25cb066408f49f07e5dd78f9b Mon Sep 17 00:00:00 2001
2 From: Antonio Quartulli <ordex@autistici.org>
3 Date: Tue, 7 May 2013 01:06:18 +0200
4 Subject: [PATCH 06/10] batman-adv: reorder clean up routine in order to avoid
5 race conditions
6
7 nc_worker accesses the originator table during its periodic
8 work, but since the originator table is freed before
9 stopping the worker this leads to a global protection fault.
10
11 Fix this by killing the worker (in nc_free) before freeing
12 the originator table.
13
14 Moreover tidy up the entire clean up routine by running all
15 the subcomponents freeing procedures first and then killing
16 the TT and the originator tables at the end.
17
18 Signed-off-by: Antonio Quartulli <ordex@autistici.org>
19 Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
20 ---
21 main.c | 16 ++++++++++++----
22 1 file changed, 12 insertions(+), 4 deletions(-)
23
24 diff --git a/main.c b/main.c
25 index 9c620cd..1240f07 100644
26 --- a/main.c
27 +++ b/main.c
28 @@ -163,14 +163,22 @@ void batadv_mesh_free(struct net_device *soft_iface)
29 batadv_vis_quit(bat_priv);
30
31 batadv_gw_node_purge(bat_priv);
32 - batadv_originator_free(bat_priv);
33 batadv_nc_free(bat_priv);
34 + batadv_dat_free(bat_priv);
35 + batadv_bla_free(bat_priv);
36
37 + /* Free the TT and the originator tables only after having terminated
38 + * all the other depending components which may use these structures for
39 + * their purposes.
40 + */
41 batadv_tt_free(bat_priv);
42
43 - batadv_bla_free(bat_priv);
44 -
45 - batadv_dat_free(bat_priv);
46 + /* Since the originator table clean up routine is accessing the TT
47 + * tables as well, it has to be invoked after the TT tables have been
48 + * freed and marked as empty. This ensures that no cleanup RCU callbacks
49 + * accessing the TT data are scheduled for later execution.
50 + */
51 + batadv_originator_free(bat_priv);
52
53 free_percpu(bat_priv->bat_counters);
54
55 --
56 1.7.10.4
57