Commit 0af31973 authored by Mitch Williams's avatar Mitch Williams Committed by Greg Kroah-Hartman

i40evf: check rings before freeing resources

[ Upstream commit fdb47ae8 ]

If the driver gets unloaded during reset recovery, it's possible
that it will attempt to free resources when they're already free.

Add a check to make sure that the Tx and Rx rings actually exist
before dereferencing them to free resources.

Change-ID: I4d2b7e9ede49f634d421a4c5deaa5446bc755eee
Signed-off-by: default avatarMitch Williams <mitch.a.williams@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 796adc85
...@@ -1864,6 +1864,9 @@ void i40evf_free_all_tx_resources(struct i40evf_adapter *adapter) ...@@ -1864,6 +1864,9 @@ void i40evf_free_all_tx_resources(struct i40evf_adapter *adapter)
{ {
int i; int i;
if (!adapter->tx_rings)
return;
for (i = 0; i < adapter->num_active_queues; i++) for (i = 0; i < adapter->num_active_queues; i++)
if (adapter->tx_rings[i]->desc) if (adapter->tx_rings[i]->desc)
i40evf_free_tx_resources(adapter->tx_rings[i]); i40evf_free_tx_resources(adapter->tx_rings[i]);
...@@ -1932,6 +1935,9 @@ void i40evf_free_all_rx_resources(struct i40evf_adapter *adapter) ...@@ -1932,6 +1935,9 @@ void i40evf_free_all_rx_resources(struct i40evf_adapter *adapter)
{ {
int i; int i;
if (!adapter->rx_rings)
return;
for (i = 0; i < adapter->num_active_queues; i++) for (i = 0; i < adapter->num_active_queues; i++)
if (adapter->rx_rings[i]->desc) if (adapter->rx_rings[i]->desc)
i40evf_free_rx_resources(adapter->rx_rings[i]); i40evf_free_rx_resources(adapter->rx_rings[i]);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment