ixgbevf: fix possible race in the reset subtask
authorEmil Tantilov <emil.s.tantilov@intel.com>
Tue, 22 May 2018 16:18:46 +0000 (09:18 -0700)
committerJeff Kirsher <jeffrey.t.kirsher@intel.com>
Mon, 4 Jun 2018 17:19:32 +0000 (10:19 -0700)
Extend the RTNL lock in ixgbevf_reset_subtask() to protect the state bits
check in addition to the call to ixgbevf_reinit_locked().

This is to make sure that we get the most up-to-date values for the bits
and avoid a possible race when going down.

Suggested-by: Zhiping du <zhipingdu@tencent.com>
Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c

index 2d5a706..59416ed 100644 (file)
@@ -3141,15 +3141,17 @@ static void ixgbevf_reset_subtask(struct ixgbevf_adapter *adapter)
        if (!test_and_clear_bit(__IXGBEVF_RESET_REQUESTED, &adapter->state))
                return;
 
+       rtnl_lock();
        /* If we're already down or resetting, just bail */
        if (test_bit(__IXGBEVF_DOWN, &adapter->state) ||
            test_bit(__IXGBEVF_REMOVING, &adapter->state) ||
-           test_bit(__IXGBEVF_RESETTING, &adapter->state))
+           test_bit(__IXGBEVF_RESETTING, &adapter->state)) {
+               rtnl_unlock();
                return;
+       }
 
        adapter->tx_timeout_count++;
 
-       rtnl_lock();
        ixgbevf_reinit_locked(adapter);
        rtnl_unlock();
 }