batman-adv: prevent potential hlist double deletion
authorMarek Lindner <mareklindner@neomailbox.ch>
Sun, 21 Jun 2015 16:30:23 +0000 (00:30 +0800)
committerAntonio Quartulli <antonio@meshcoding.com>
Mon, 24 Aug 2015 22:12:21 +0000 (00:12 +0200)
The hlist_del_rcu() call in batadv_tt_global_size_mod() does not check
if the element still is part of the list prior to deletion. The atomic
list counter should prevent the worst but converting to
hlist_del_init_rcu() ensures the element can't be deleted more than
once.

Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
net/batman-adv/translation-table.c

index 9e1f866a59f4fed44098bbd66a06de2fde1a6f3a..596e326b01d010c69103a02b10dbca0fc2b14d40 100644 (file)
@@ -315,7 +315,7 @@ 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_rcu(&vlan->list);
+               hlist_del_init_rcu(&vlan->list);
                spin_unlock_bh(&orig_node->vlan_list_lock);
                batadv_orig_node_vlan_free_ref(vlan);
        }