i40evf: fix multiple crashes on remove
authorMitch Williams <mitch.a.williams@intel.com>
Fri, 21 Feb 2014 03:29:07 +0000 (19:29 -0800)
committerDavid S. Miller <davem@davemloft.net>
Fri, 21 Feb 2014 17:38:25 +0000 (12:38 -0500)
Depending upon the state of the driver, there are several potential
pitfalls on remove. Kill the watchdog task so rmmod doesn't hang.
Check the adapter->msix_entries field, not the num_msix_vectors field,
which is never cleared.

Change-ID: I0546048477f09fc19e481bd37efa30daae4faa88
Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Signed-off-by: Jesse Brandeburg <jesse.brandeburg@intel.com>
Tested-by: Sibai Li <sibai.li@intel.com>
Signed-off-by: Aaron Brown <aaron.f.brown@intel.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/intel/i40evf/i40evf_main.c

index 75a2c6f19121ab9617a2f2e1137b7edf86db82e6..e0eb27dc36de2205b3b513fcecfbc0bbfc67e54f 100644 (file)
@@ -215,6 +215,9 @@ static void i40evf_irq_disable(struct i40evf_adapter *adapter)
        int i;
        struct i40e_hw *hw = &adapter->hw;
 
+       if (!adapter->msix_entries)
+               return;
+
        for (i = 1; i < adapter->num_msix_vectors; i++) {
                wr32(hw, I40E_VFINT_DYN_CTLN1(i - 1), 0);
                synchronize_irq(adapter->msix_entries[i].vector);
@@ -2372,17 +2375,15 @@ static void i40evf_remove(struct pci_dev *pdev)
        }
        adapter->state = __I40EVF_REMOVE;
 
-       if (adapter->num_msix_vectors) {
+       if (adapter->msix_entries) {
                i40evf_misc_irq_disable(adapter);
-               del_timer_sync(&adapter->watchdog_timer);
-
-               flush_scheduled_work();
-
                i40evf_free_misc_irq(adapter);
-
                i40evf_reset_interrupt_capability(adapter);
        }
 
+       del_timer_sync(&adapter->watchdog_timer);
+       flush_scheduled_work();
+
        if (hw->aq.asq.count)
                i40evf_shutdown_adminq(hw);