* [B.A.T.M.A.N.] [PATCHv2 maint] batman-adv: reorder clean up routine in order to avoid race conditions
@ 2013-05-06 23:06 Antonio Quartulli
2013-05-09 9:31 ` Marek Lindner
0 siblings, 1 reply; 2+ messages in thread
From: Antonio Quartulli @ 2013-05-06 23:06 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Antonio Quartulli
nc_worker accesses the originator table during its periodic
work, but since the originator table is freed before
stopping the worker this leads to a global protection fault.
Fix this by killing the worker (in nc_free) before freeing
the originator table.
Moreover tidy up the entire clean up routine by running all
the subcomponents freeing procedures first and then killing
the TT and the originator tables at the end.
Signed-off-by: Antonio Quartulli <ordex@autistici.org>
---
v2:
- based on top of maint
- commit message reworded
main.c | 16 ++++++++++++----
1 file changed, 12 insertions(+), 4 deletions(-)
diff --git a/main.c b/main.c
index 9c620cd..6fefcb1 100644
--- a/main.c
+++ b/main.c
@@ -163,14 +163,22 @@ void batadv_mesh_free(struct net_device *soft_iface)
batadv_vis_quit(bat_priv);
batadv_gw_node_purge(bat_priv);
- batadv_originator_free(bat_priv);
batadv_nc_free(bat_priv);
+ batadv_dat_free(bat_priv);
+ batadv_bla_free(bat_priv);
+ /* free the TT and the originator tables only after having terminated all
+ * the other minor components which may use these structures for their
+ * purposes
+ */
batadv_tt_free(bat_priv);
- batadv_bla_free(bat_priv);
-
- batadv_dat_free(bat_priv);
+ /* since the originator clean up routine is the one accessing the TT
+ * tables as well, invoke it as last step so that any race condition is
+ * avoided when the RCU callbacks scheduled by this function access the
+ * TT data
+ */
+ batadv_originator_free(bat_priv);
free_percpu(bat_priv->bat_counters);
--
1.8.1.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [B.A.T.M.A.N.] [PATCHv2 maint] batman-adv: reorder clean up routine in order to avoid race conditions
2013-05-06 23:06 [B.A.T.M.A.N.] [PATCHv2 maint] batman-adv: reorder clean up routine in order to avoid race conditions Antonio Quartulli
@ 2013-05-09 9:31 ` Marek Lindner
0 siblings, 0 replies; 2+ messages in thread
From: Marek Lindner @ 2013-05-09 9:31 UTC (permalink / raw)
To: b.a.t.m.a.n; +Cc: Antonio Quartulli
On Tuesday, May 07, 2013 07:06:18 Antonio Quartulli wrote:
> nc_worker accesses the originator table during its periodic
> work, but since the originator table is freed before
> stopping the worker this leads to a global protection fault.
>
> Fix this by killing the worker (in nc_free) before freeing
> the originator table.
>
> Moreover tidy up the entire clean up routine by running all
> the subcomponents freeing procedures first and then killing
> the TT and the originator tables at the end.
>
> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
> ---
>
> v2:
> - based on top of maint
> - commit message reworded
>
> main.c | 16 ++++++++++++----
> 1 file changed, 12 insertions(+), 4 deletions(-)
Applied in revision 763f413.
Thanks,
Marek
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-05-09 9:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-05-06 23:06 [B.A.T.M.A.N.] [PATCHv2 maint] batman-adv: reorder clean up routine in order to avoid race conditions Antonio Quartulli
2013-05-09 9:31 ` Marek Lindner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox