summaryrefslogtreecommitdiffstats
path: root/net/tipc/bearer.c
diff options
context:
space:
mode:
authorYing Xue <ying.xue@windriver.com>2014-04-21 04:55:51 +0200
committerDavid S. Miller <davem@davemloft.net>2014-04-23 03:17:53 +0200
commit28dd94187afd660a350d01d6bad4a915a6d570b8 (patch)
treec53e49a95c682a5d656fa7e95d847a8ae10aeb50 /net/tipc/bearer.c
parenttipc: use bearer_disable to disable bearer in tipc_l2_device_event (diff)
downloadlinux-28dd94187afd660a350d01d6bad4a915a6d570b8.tar.xz
linux-28dd94187afd660a350d01d6bad4a915a6d570b8.zip
tipc: use bc_lock to protect node map in bearer structure
The node map variable - 'nodes' in bearer structure is only used by bclink. When bclink accesses it, bc_lock is held. But when change it, for instance, in tipc_bearer_add_dest() or tipc_bearer_remove_dest() the bc_lock is not taken at all. To avoid any inconsistent data, we should always grab bc_lock while accessing node map variable. Signed-off-by: Ying Xue <ying.xue@windriver.com> Reviewed-by: Jon Maloy <jon.maloy@ericsson.com> Reviewed-by: Erik Hugne <erik.hugne@ericsson.com> Tested-by: Erik Hugne <erik.hugne@ericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'net/tipc/bearer.c')
-rw-r--r--net/tipc/bearer.c6
1 files changed, 2 insertions, 4 deletions
diff --git a/net/tipc/bearer.c b/net/tipc/bearer.c
index 44fd22a0c070..3abd9702b887 100644
--- a/net/tipc/bearer.c
+++ b/net/tipc/bearer.c
@@ -220,8 +220,7 @@ void tipc_bearer_add_dest(u32 bearer_id, u32 dest)
rcu_read_lock();
b_ptr = rcu_dereference_rtnl(bearer_list[bearer_id]);
if (b_ptr) {
- tipc_nmap_add(&b_ptr->nodes, dest);
- tipc_bcbearer_sort();
+ tipc_bcbearer_sort(&b_ptr->nodes, dest, true);
tipc_disc_add_dest(b_ptr->link_req);
}
rcu_read_unlock();
@@ -234,8 +233,7 @@ void tipc_bearer_remove_dest(u32 bearer_id, u32 dest)
rcu_read_lock();
b_ptr = rcu_dereference_rtnl(bearer_list[bearer_id]);
if (b_ptr) {
- tipc_nmap_remove(&b_ptr->nodes, dest);
- tipc_bcbearer_sort();
+ tipc_bcbearer_sort(&b_ptr->nodes, dest, false);
tipc_disc_remove_dest(b_ptr->link_req);
}
rcu_read_unlock();