Skip to content

Commit

Permalink
batman-adv: Only put orig_node_vlan list reference when removed
Browse files Browse the repository at this point in the history
The batadv_orig_node_vlan reference counter in batadv_tt_global_size_mod
can only be reduced when the list entry was actually removed. Otherwise the
reference counter may reach zero when batadv_tt_global_size_mod is called
from two different contexts for the same orig_node_vlan but only one
context is actually removing the entry from the list.

The release function for this orig_node_vlan is not called inside the
vlan_list_lock spinlock protected region because the function
batadv_tt_global_size_mod still holds a orig_node_vlan reference for the
object pointer on the stack. Thus the actual release function (when
required) will be called only at the end of the function.

Fixes: 7ea7b4a ("batman-adv: make the TT CRC logic VLAN specific")
Signed-off-by: Sven Eckelmann <[email protected]>
Signed-off-by: Marek Lindner <[email protected]>
Signed-off-by: Antonio Quartulli <[email protected]>
  • Loading branch information
ecsv authored and ordex committed Feb 16, 2016
1 parent c18bdd0 commit 3db1520
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions net/batman-adv/translation-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,11 @@ static void batadv_tt_global_size_mod(struct batadv_orig_node *orig_node,

if (atomic_add_return(v, &vlan->tt.num_entries) == 0) {
spin_lock_bh(&orig_node->vlan_list_lock);
hlist_del_init_rcu(&vlan->list);
if (!hlist_unhashed(&vlan->list)) {
hlist_del_init_rcu(&vlan->list);
batadv_orig_node_vlan_free_ref(vlan);
}
spin_unlock_bh(&orig_node->vlan_list_lock);
batadv_orig_node_vlan_free_ref(vlan);
}

batadv_orig_node_vlan_free_ref(vlan);
Expand Down

0 comments on commit 3db1520

Please sign in to comment.