Commit 01df2b65 authored by Marek Lindner's avatar Marek Lindner Committed by Sven Eckelmann

batman-adv: Fix refcount imbalance in find_router

Signed-off-by: default avatarMarek Lindner <lindner_marek@yahoo.de>
Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
parent 3a4375a9
...@@ -1213,7 +1213,7 @@ struct neigh_node *find_router(struct bat_priv *bat_priv, ...@@ -1213,7 +1213,7 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
router = orig_node_get_router(orig_node); router = orig_node_get_router(orig_node);
if (!router) if (!router)
return NULL; goto err;
/* without bonding, the first node should /* without bonding, the first node should
* always choose the default router. */ * always choose the default router. */
...@@ -1222,10 +1222,8 @@ struct neigh_node *find_router(struct bat_priv *bat_priv, ...@@ -1222,10 +1222,8 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
rcu_read_lock(); rcu_read_lock();
/* select default router to output */ /* select default router to output */
router_orig = router->orig_node; router_orig = router->orig_node;
if (!router_orig) { if (!router_orig)
rcu_read_unlock(); goto err_unlock;
return NULL;
}
if ((!recv_if) && (!bonding_enabled)) if ((!recv_if) && (!bonding_enabled))
goto return_router; goto return_router;
...@@ -1268,6 +1266,12 @@ struct neigh_node *find_router(struct bat_priv *bat_priv, ...@@ -1268,6 +1266,12 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
return_router: return_router:
rcu_read_unlock(); rcu_read_unlock();
return router; return router;
err_unlock:
rcu_read_unlock();
err:
if (router)
neigh_node_free_ref(router);
return NULL;
} }
static int check_unicast_packet(struct sk_buff *skb, int hdr_size) static int check_unicast_packet(struct sk_buff *skb, int hdr_size)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment