aboutsummaryrefslogtreecommitdiffstats
path: root/net/batman-adv/routing.c
diff options
context:
space:
mode:
authorSven Eckelmann <sven@narfation.org>2012-08-20 04:26:49 -0400
committerAntonio Quartulli <ordex@autistici.org>2012-10-29 04:42:38 -0400
commitfe3f4cfe8ef8b4f0979a0dd61f60de832848664a (patch)
tree2b1ccaecbee36f0a323fa65d6a40e969516a5822 /net/batman-adv/routing.c
parentbd5b80d51a6c4a68f7d4b9b92c495329f47e53d4 (diff)
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: Sven Eckelmann <sven@narfation.org> Signed-off-by: Antonio Quartulli <ordex@autistici.org>
Diffstat (limited to 'net/batman-adv/routing.c')
-rw-r--r--net/batman-adv/routing.c23
1 files changed, 8 insertions, 15 deletions
diff --git a/net/batman-adv/routing.c b/net/batman-adv/routing.c
index 8bdafc85ba4f..1ac072d7409e 100644
--- a/net/batman-adv/routing.c
+++ b/net/batman-adv/routing.c
@@ -549,25 +549,18 @@ batadv_find_ifalter_router(struct batadv_orig_node *primary_orig,
549 if (tmp_neigh_node->if_incoming == recv_if) 549 if (tmp_neigh_node->if_incoming == recv_if)
550 continue; 550 continue;
551 551
552 if (!atomic_inc_not_zero(&tmp_neigh_node->refcount)) 552 if (router && tmp_neigh_node->tq_avg <= router->tq_avg)
553 continue; 553 continue;
554 554
555 /* if we don't have a router yet 555 if (!atomic_inc_not_zero(&tmp_neigh_node->refcount))
556 * or this one is better, choose it. 556 continue;
557 */
558 if ((!router) ||
559 (tmp_neigh_node->tq_avg > router->tq_avg)) {
560 /* decrement refcount of
561 * previously selected router
562 */
563 if (router)
564 batadv_neigh_node_free_ref(router);
565 557
566 router = tmp_neigh_node; 558 /* decrement refcount of previously selected router */
567 atomic_inc_not_zero(&router->refcount); 559 if (router)
568 } 560 batadv_neigh_node_free_ref(router);
569 561
570 batadv_neigh_node_free_ref(tmp_neigh_node); 562 /* we found a better router (or at least one valid router) */
563 router = tmp_neigh_node;
571 } 564 }
572 565
573 /* use the first candidate if nothing was found. */ 566 /* use the first candidate if nothing was found. */