net: ena: fix surprise unplug NULL dereference kernel crash

Starting with driver version 1.5.0, in case of a surprise device
unplug, there is a race caused by invoking ena_destroy_device()
from two different places. As a result, the readless register might
be accessed after it was destroyed.

Signed-off-by: Netanel Belgazal <netanel@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Netanel Belgazal 2018-09-09 08:15:20 +00:00 committed by David S. Miller
parent 5cf4a8532c
commit 772ed869f5
1 changed files with 2 additions and 2 deletions

View File

@ -3409,12 +3409,12 @@ static void ena_remove(struct pci_dev *pdev)
netdev->rx_cpu_rmap = NULL; netdev->rx_cpu_rmap = NULL;
} }
#endif /* CONFIG_RFS_ACCEL */ #endif /* CONFIG_RFS_ACCEL */
unregister_netdev(netdev);
del_timer_sync(&adapter->timer_service); del_timer_sync(&adapter->timer_service);
cancel_work_sync(&adapter->reset_task); cancel_work_sync(&adapter->reset_task);
unregister_netdev(netdev);
/* Reset the device only if the device is running. */ /* Reset the device only if the device is running. */
if (test_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags)) if (test_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags))
ena_com_dev_reset(ena_dev, adapter->reset_reason); ena_com_dev_reset(ena_dev, adapter->reset_reason);