batman-adv: bugfixes for the 2011.3.1 release
[feed/routing.git] / patches / 0003-batman-adv_remove_references_for_global_tt_entries.patch
1
2 struct tt_global_entry holds a reference to an orig_node which must be
3 decremented before deallocating the structure.
4
5 Signed-off-by: Simon Wunderlich <siwu@hrz.tu-chemnitz.de>
6 ---
7 compat.c | 8 --------
8 compat.h | 1 -
9 translation-table.c | 14 +++++++++++++-
10 3 files changed, 13 insertions(+), 10 deletions(-)
11
12 --- a/compat.c
13 +++ b/compat.c
14 @@ -36,12 +36,4 @@ void free_rcu_tt_local_entry(struct rcu_head *rcu)
15 kfree(tt_local_entry);
16 }
17
18 -void free_rcu_tt_global_entry(struct rcu_head *rcu)
19 -{
20 - struct tt_global_entry *tt_global_entry;
21 -
22 - tt_global_entry = container_of(rcu, struct tt_global_entry, rcu);
23 - kfree(tt_global_entry);
24 -}
25 -
26 #endif /* < KERNEL_VERSION(3, 0, 0) */
27 --- a/compat.h
28 +++ b/compat.h
29 @@ -63,7 +63,6 @@ void free_rcu_gw_node(struct rcu_head *rcu);
30 void free_rcu_neigh_node(struct rcu_head *rcu);
31 void free_rcu_softif_neigh(struct rcu_head *rcu);
32 void free_rcu_tt_local_entry(struct rcu_head *rcu);
33 -void free_rcu_tt_global_entry(struct rcu_head *rcu);
34
35 #endif /* < KERNEL_VERSION(3, 0, 0) */
36
37 --- a/translation-table.c
38 +++ b/translation-table.c
39 @@ -137,10 +137,22 @@ static void tt_local_entry_free_ref(struct tt_local_entry *tt_local_entry)
40 kfree_rcu(tt_local_entry, rcu);
41 }
42
43 +static void tt_global_entry_free_rcu(struct rcu_head *rcu)
44 +{
45 + struct tt_global_entry *tt_global_entry;
46 +
47 + tt_global_entry = container_of(rcu, struct tt_global_entry, rcu);
48 +
49 + if (tt_global_entry->orig_node)
50 + orig_node_free_ref(tt_global_entry->orig_node);
51 +
52 + kfree(tt_global_entry);
53 +}
54 +
55 static void tt_global_entry_free_ref(struct tt_global_entry *tt_global_entry)
56 {
57 if (atomic_dec_and_test(&tt_global_entry->refcount))
58 - kfree_rcu(tt_global_entry, rcu);
59 + call_rcu(&tt_global_entry->rcu, tt_global_entry_free_rcu);
60 }
61
62 static void tt_local_event(struct bat_priv *bat_priv, const uint8_t *addr,
63