batman-adv: protect neighbor nodes with reference counters

Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
This commit is contained in:
Marek Lindner
2010-12-12 21:57:10 +00:00
parent 8d68921856
commit a8e7f4bc38
4 changed files with 28 additions and 8 deletions

View File

@@ -89,6 +89,8 @@ static void update_route(struct bat_priv *bat_priv,
struct neigh_node *neigh_node,
unsigned char *hna_buff, int hna_buff_len)
{
struct neigh_node *neigh_node_tmp;
/* route deleted */
if ((orig_node->router) && (!neigh_node)) {
@@ -115,7 +117,12 @@ static void update_route(struct bat_priv *bat_priv,
orig_node->router->addr);
}
if (neigh_node)
kref_get(&neigh_node->refcount);
neigh_node_tmp = orig_node->router;
orig_node->router = neigh_node;
if (neigh_node_tmp)
kref_put(&neigh_node_tmp->refcount, neigh_node_free_ref);
}