• Ying Xue's avatar
    tipc: involve reference counter for subscriber · 00bc00a9
    Ying Xue authored
    At present subscriber's lock is used to protect the subscription list
    of subscriber as well as subscriptions linked into the list. While one
    or all subscriptions are deleted through iterating the list, the
    subscriber's lock must be held. Meanwhile, as deletion of subscription
    may happen in subscription timer's handler, the lock must be grabbed
    in the function as well. When subscription's timer is terminated with
    del_timer_sync() during above iteration, subscriber's lock has to be
    temporarily released, otherwise, deadlock may occur. However, the
    temporary release may cause the double free of a subscription as the
    subscription is not disconnected from the subscription list.
    
    Now if a reference counter is introduced to subscriber, subscription's
    timer can be asynchronously stopped with del_timer(). As a result, the
    issue is not only able to be fixed, but also relevant code is pretty
    readable and understandable.
    Signed-off-by: default avatarYing Xue <ying.xue@windriver.com>
    Reviewed-by: default avatarJon Maloy <jon.maloy@ericson.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    00bc00a9
subscr.c 10.6 KB