• Somnath Kotur's avatar
    bnxt_re: Fix race between the netdev register and unregister events · d5917307
    Somnath Kotur authored
    Upon receipt of the NETDEV_REGISTER event from the netdev notifier chain,
    the IB stack registration is spawned off to a workqueue since that also
    requires an rtnl lock.
    There could be 2 kinds of races between the NETDEV_REGISTER and the
    NETDEV_UNREGISTER event handling.
    a)The NETDEV_UNREGISTER event is received in rapid succession after
    the NETDEV_REGISTER event even before the work queue got a chance to run.
    b)The NETDEV_UNREGISTER event is received while the workqueue that handles
    registration with the IB stack is still in progress.
    
    Handle both the races with a bit flag that is set just before the work item
    is queued and cleared in the workqueue after the event is handled just
    before the workqueue item is freed.
    
    While adding the new flag, it was noted that the flags are all used in
    *_bit() operations which expect a bit number and not a literal constant
    with a bit set.  So change the numbers to be bit numbers.
    Signed-off-by: default avatarSomnath Kotur <somnath.kotur@broadcom.com>
    Signed-off-by: default avatarDoug Ledford <dledford@redhat.com>
    d5917307
main.c 36.5 KB