Commit 074bb43e authored by Jon Paul Maloy's avatar Jon Paul Maloy Committed by David S. Miller

tipc: fix a loop style problem

In commit 7d33939f
("tipc: delay delete of link when failover is needed") we
introduced a loop for finding and removing a link pointer
in an array. The removal is done after we have left the loop,
giving the impression that one may remove the wrong pointer
if no matching element is found.

This is not really a bug, since we know that there will always
be a matching element, but it looks wrong, and causes a smatch
warning.

We fix this loop with this commit.
Signed-off-by: default avatarJon Maloy <jon.maloy@ericsson.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 6dd3c9ec
...@@ -252,12 +252,12 @@ void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr) ...@@ -252,12 +252,12 @@ void tipc_node_detach_link(struct tipc_node *n_ptr, struct tipc_link *l_ptr)
int i; int i;
for (i = 0; i < MAX_BEARERS; i++) { for (i = 0; i < MAX_BEARERS; i++) {
if (l_ptr == n_ptr->links[i]) if (l_ptr != n_ptr->links[i])
break; continue;
}
n_ptr->links[i] = NULL; n_ptr->links[i] = NULL;
atomic_dec(&tipc_num_links); atomic_dec(&tipc_num_links);
n_ptr->link_cnt--; n_ptr->link_cnt--;
}
} }
static void node_established_contact(struct tipc_node *n_ptr) static void node_established_contact(struct tipc_node *n_ptr)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment