Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fe3f4cfe authored by Sven Eckelmann's avatar Sven Eckelmann Committed by Antonio Quartulli
Browse files

batman-adv: Only increase refcounter once for alternate router



The test whether we can use a router for alternating bonding should only be
done once because it is already known that it is still usable and will not be
deleted from the list soon.

This patch addresses Coverity #712285: Unchecked return value

Signed-off-by: default avatarSven Eckelmann <sven@narfation.org>
Signed-off-by: default avatarAntonio Quartulli <ordex@autistici.org>
parent bd5b80d5
Loading
Loading
Loading
Loading
+8 −15
Original line number Original line Diff line number Diff line
@@ -549,25 +549,18 @@ batadv_find_ifalter_router(struct batadv_orig_node *primary_orig,
		if (tmp_neigh_node->if_incoming == recv_if)
		if (tmp_neigh_node->if_incoming == recv_if)
			continue;
			continue;


		if (router && tmp_neigh_node->tq_avg <= router->tq_avg)
			continue;

		if (!atomic_inc_not_zero(&tmp_neigh_node->refcount))
		if (!atomic_inc_not_zero(&tmp_neigh_node->refcount))
			continue;
			continue;


		/* if we don't have a router yet
		/* decrement refcount of previously selected router */
		 * or this one is better, choose it.
		 */
		if ((!router) ||
		    (tmp_neigh_node->tq_avg > router->tq_avg)) {
			/* decrement refcount of
			 * previously selected router
			 */
		if (router)
		if (router)
			batadv_neigh_node_free_ref(router);
			batadv_neigh_node_free_ref(router);


		/* we found a better router (or at least one valid router) */
		router = tmp_neigh_node;
		router = tmp_neigh_node;
			atomic_inc_not_zero(&router->refcount);
		}

		batadv_neigh_node_free_ref(tmp_neigh_node);
	}
	}


	/* use the first candidate if nothing was found. */
	/* use the first candidate if nothing was found. */