[linux-next] LinuxNextTracking branch, master, updated. next-20160512

batman at open-mesh.org batman at open-mesh.org
Fri May 13 00:15:43 CEST 2016

The following commit has been merged in the master branch:
commit f0b94ebccd2b924237ca7a101da3db70c3a8f0f2
Author: Sven Eckelmann <sven at narfation.org>
Date:   Sat Mar 5 19:05:24 2016 +0100

    batman-adv: Use kref_get for _batadv_update_route
    _batadv_update_route requires that the caller already has a valid reference
    for neigh_node. It is therefore not possible that it has an reference
    counter of 0 and was still given to this function
    The kref_get function instead WARNs (with debug information) when the
    reference counter would still be 0. This makes a bug in batman-adv better
    visible because kref_get_unless_zero would have ignored this problem.
    Signed-off-by: Sven Eckelmann <sven at narfation.org>
    Signed-off-by: Marek Lindner <mareklindner at neomailbox.ch>
    Signed-off-by: Antonio Quartulli <a at unstable.cc>

diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 2ecfca2..b494e43 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -100,10 +100,6 @@ static void _batadv_update_route(struct batadv_priv *bat_priv,
 	if (curr_router)
-	/* increase refcount of new best neighbor */
-	if (neigh_node && !kref_get_unless_zero(&neigh_node->refcount))
-		neigh_node = NULL;
 	/* curr_router used earlier may not be the current orig_ifinfo->router
 	 * anymore because it was dereferenced outside of the neigh_list_lock
@@ -114,6 +110,10 @@ static void _batadv_update_route(struct batadv_priv *bat_priv,
 	curr_router = rcu_dereference_protected(orig_ifinfo->router, true);
+	/* increase refcount of new best neighbor */
+	if (neigh_node)
+		kref_get(&neigh_node->refcount);
 	rcu_assign_pointer(orig_ifinfo->router, neigh_node);


More information about the linux-merge mailing list