summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorMarek Lindner <lindner_marek@yahoo.de>2011-05-05 14:14:46 +0200
committerSven Eckelmann <sven@narfation.org>2011-05-08 16:10:42 +0200
commit01df2b65e97735547ce37844f4134b5ea99b4037 (patch)
tree796500d41c64fc122bb54ed00927bf75db2eb638 /net
parent3a4375a9f0080e6ae40af63e2e2c1e70a6dcb775 (diff)
downloadlinux-01df2b65e97735547ce37844f4134b5ea99b4037.tar.gz
linux-01df2b65e97735547ce37844f4134b5ea99b4037.tar.bz2
linux-01df2b65e97735547ce37844f4134b5ea99b4037.zip
batman-adv: Fix refcount imbalance in find_router
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de> Signed-off-by: Sven Eckelmann <sven@narfation.org>
Diffstat (limited to 'net')
-rw-r--r--net/batman-adv/routing.c14
1 files changed, 9 insertions, 5 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 49f571553050..d8cde2b8d1cf 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -1213,7 +1213,7 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
router = orig_node_get_router(orig_node);
if (!router)
- return NULL;
+ goto err;
/* without bonding, the first node should
* always choose the default router. */
@@ -1222,10 +1222,8 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
rcu_read_lock();
/* select default router to output */
router_orig = router->orig_node;
- if (!router_orig) {
- rcu_read_unlock();
- return NULL;
- }
+ if (!router_orig)
+ goto err_unlock;
if ((!recv_if) && (!bonding_enabled))
goto return_router;
@@ -1268,6 +1266,12 @@ struct neigh_node *find_router(struct bat_priv *bat_priv,
return_router:
rcu_read_unlock();
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)