• Jon Paul Maloy's avatar
    tipc: add node_lock protection to link lookup function · e099e86c
    Jon Paul Maloy authored
    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: default avatarJon Maloy <jon.maloy@ericsson.com>
    Reviewed-by: default avatarYing Xue <ying.xue@windriver.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    e099e86c
link.c 74.3 KB