Skip to content

Commit

Permalink
batman-adv: protect tt request from double deletion
Browse files Browse the repository at this point in the history
The list_del() calls were changed to list_del_init() to prevent
an accidental double deletion in batadv_tt_req_node_new().

Signed-off-by: Marek Lindner <mareklindner@neomailbox.ch>
Signed-off-by: Antonio Quartulli <antonio@meshcoding.com>
  • Loading branch information
Marek Lindner authored and Antonio Quartulli committed Aug 14, 2015
1 parent 8a4023c commit 1f15510
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions net/batman-adv/translation-table.c
Original file line number Diff line number Diff line change
Expand Up @@ -2196,7 +2196,7 @@ static void batadv_tt_req_list_free(struct batadv_priv *bat_priv)
spin_lock_bh(&bat_priv->tt.req_list_lock);

list_for_each_entry_safe(node, safe, &bat_priv->tt.req_list, list) {
list_del(&node->list);
list_del_init(&node->list);
kfree(node);
}

Expand Down Expand Up @@ -2232,7 +2232,7 @@ static void batadv_tt_req_purge(struct batadv_priv *bat_priv)
list_for_each_entry_safe(node, safe, &bat_priv->tt.req_list, list) {
if (batadv_has_timed_out(node->issued_at,
BATADV_TT_REQUEST_TIMEOUT)) {
list_del(&node->list);
list_del_init(&node->list);
kfree(node);
}
}
Expand Down Expand Up @@ -2514,7 +2514,8 @@ static int batadv_send_tt_request(struct batadv_priv *bat_priv,
batadv_hardif_free_ref(primary_if);
if (ret && tt_req_node) {
spin_lock_bh(&bat_priv->tt.req_list_lock);
list_del(&tt_req_node->list);
/* list_del_init() verifies tt_req_node still is in the list */
list_del_init(&tt_req_node->list);
spin_unlock_bh(&bat_priv->tt.req_list_lock);
kfree(tt_req_node);
}
Expand Down Expand Up @@ -2951,7 +2952,7 @@ static void batadv_handle_tt_response(struct batadv_priv *bat_priv,
list_for_each_entry_safe(node, safe, &bat_priv->tt.req_list, list) {
if (!batadv_compare_eth(node->addr, resp_src))
continue;
list_del(&node->list);
list_del_init(&node->list);
kfree(node);
}

Expand Down

0 comments on commit 1f15510

Please sign in to comment.