tipc: use node list lock to protect tipc_num_links variable
authorYing Xue <ying.xue@windriver.com>
Thu, 27 Mar 2014 04:54:39 +0000 (12:54 +0800)
committerDavid S. Miller <davem@davemloft.net>
Thu, 27 Mar 2014 17:08:38 +0000 (13:08 -0400)
commitdde2026608fbf24e1687a2b62c4752022f429252
tree829cd112db96c7c1e7fcacb9544f36703c06ac4a
parent2220646a53aa588798653232e26172ec36ab06cd
tipc: use node list lock to protect tipc_num_links variable

Without properly implicit or explicit read memory barrier, it's
unsafe to read an atomic variable with atomic_read() from another
thread which is different with the thread of changing the atomic
variable with atomic_inc() or atomic_dec(). So a stale tipc_num_links
may be got with atomic_read() in tipc_node_get_links(). If the
tipc_num_links variable type is converted from atomic to unsigned
integer and node list lock is used to protect it, the issue would
be avoided.

Signed-off-by: Ying Xue <ying.xue@windriver.com>
Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/tipc/node.c