[v2] batman-adv: Fix refcount imbalance in find_router

Message ID 1304597949-17173-1-git-send-email-lindner_marek@yahoo.de (mailing list archive)
State Accepted, archived
Headers

Commit Message

Marek Lindner May 5, 2011, 12:19 p.m. UTC
  Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
---
Fixed wrong subject.

 routing.c |   14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)
  

Comments

Sven Eckelmann May 5, 2011, 7:01 p.m. UTC | #1
Marek Lindner wrote:
> Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>

Acked-by: Sven Eckelmann <sven@narfation.org>
  
Marek Lindner May 5, 2011, 11:05 p.m. UTC | #2
On Thursday 05 May 2011 21:01:43 Sven Eckelmann wrote:
> Marek Lindner wrote:
> > Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
> 
> Acked-by: Sven Eckelmann <sven@narfation.org>

Applied in revision ca6b80c.

Thanks for the review,
Marek
  

Patch

diff --git a/routing.c b/routing.c
index 49f5715..d8cde2b 100644
--- a/routing.c
+++ b/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)