]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
i40evf: protect against NULL msix_entries and q_vectors pointers
authorJacob Keller <jacob.e.keller@intel.com>
Tue, 8 Nov 2016 21:05:08 +0000 (13:05 -0800)
committerDhaval Giani <dhaval.giani@oracle.com>
Wed, 8 Mar 2017 00:41:22 +0000 (19:41 -0500)
Orabug: 24568124

Update the functions which free msix_entries and q_vectors so that they
are safe against NULL values. This allows calling code to not care
whether these have already been freed when disabling and freeing them.

Change-ID: I31bfd1c0da18023d971b618edc6fb049721f3298
Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
Tested-by: Andrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
(cherry picked from commit ef4603e82f64605e73495c26050f3f236609d991)
Signed-off-by: Brian Maly <brian.maly@oracle.com>
Signed-off-by: Dhaval Giani <dhaval.giani@oracle.com>
drivers/net/ethernet/intel/i40evf/i40evf_main.c

index 426a766f7442b32fb09f0dbd1dd35e0dc9638383..c69e6f4a1e3e7607aa51f8fd655ab78748d2a6fe 100644 (file)
@@ -209,6 +209,9 @@ static void i40evf_misc_irq_disable(struct i40evf_adapter *adapter)
 {
        struct i40e_hw *hw = &adapter->hw;
 
+       if (!adapter->msix_entries)
+               return;
+
        wr32(hw, I40E_VFINT_DYN_CTL01, 0);
 
        /* read flush */
@@ -656,6 +659,9 @@ static void i40evf_free_misc_irq(struct i40evf_adapter *adapter)
 {
        struct net_device *netdev = adapter->netdev;
 
+       if (!adapter->msix_entries)
+               return;
+
        free_irq(adapter->msix_entries[0].vector, netdev);
 }
 
@@ -1430,6 +1436,9 @@ static void i40evf_free_q_vectors(struct i40evf_adapter *adapter)
        int q_idx, num_q_vectors;
        int napi_vectors;
 
+       if (!adapter->q_vectors)
+               return;
+
        num_q_vectors = adapter->num_msix_vectors - NONQ_VECS;
        napi_vectors = adapter->num_active_queues;
 
@@ -1439,6 +1448,7 @@ static void i40evf_free_q_vectors(struct i40evf_adapter *adapter)
                        netif_napi_del(&q_vector->napi);
        }
        kfree(adapter->q_vectors);
+       adapter->q_vectors = NULL;
 }
 
 /**
@@ -2857,12 +2867,10 @@ static void i40evf_remove(struct pci_dev *pdev)
                msleep(50);
        }
 
-       if (adapter->msix_entries) {
-               i40evf_misc_irq_disable(adapter);
-               i40evf_free_misc_irq(adapter);
-               i40evf_reset_interrupt_capability(adapter);
-               i40evf_free_q_vectors(adapter);
-       }
+       i40evf_misc_irq_disable(adapter);
+       i40evf_free_misc_irq(adapter);
+       i40evf_reset_interrupt_capability(adapter);
+       i40evf_free_q_vectors(adapter);
 
        if (adapter->watchdog_timer.function)
                del_timer_sync(&adapter->watchdog_timer);