OSDN Git Service

tipc: add node_lock protection to link lookup function
authorJon Paul Maloy <jon.maloy@ericsson.com>
Thu, 13 Feb 2014 22:29:18 +0000 (17:29 -0500)
committerDavid S. Miller <davem@davemloft.net>
Thu, 13 Feb 2014 22:57:07 +0000 (17:57 -0500)
commite099e86c9e24fe9aff36773600543eb31d8954d1
tree723936589e12e2bdcbf6aa8b702122b7488cec5e
parenta83045292daf9f07d0b103e5715ef527123d2fcc
tipc: add node_lock protection to link lookup function

In an earlier commit, ("tipc: remove links list from bearer struct")
we described three issues that need to be pre-emptively resolved before
we can remove tipc_net_lock. Here we resolve issue a) described in that
commit:

"a) In access method #2, we access the link before taking the
    protecting node_lock. This will not work once net_lock is gone,
    so we will have to change the access order. We will deal with
    this in a later commit in this series."

Here, we change that access order, by ensuring that the function
link_find_link() returns only a safe reference for finding
the link, i.e., a node pointer and an index into its 'links' array,
not the link pointer itself. We also change all callers of this
function to first take the node lock before they can check if there
still is a valid link pointer at the returned index. Since the
function now returns a node pointer rather than a link pointer,
we rename it to the more appropriate 'tipc_link_find_owner().

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