]> git.proxmox.com Git - mirror_ubuntu-disco-kernel.git/commitdiff
batman-adv: Fix refcount imbalance in find_router
authorMarek Lindner <lindner_marek@yahoo.de>
Thu, 5 May 2011 12:14:46 +0000 (14:14 +0200)
committerSven Eckelmann <sven@narfation.org>
Sun, 8 May 2011 14:10:42 +0000 (16:10 +0200)
Signed-off-by: Marek Lindner <lindner_marek@yahoo.de>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
net/batman-adv/routing.c

index 49f57155305088e9d777c1ced4e6720ab25cb8d9..d8cde2b8d1cf62175c6c40009d6c8b38d000bc9d 100644 (file)
@@ -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)