From: Netanel Belgazal Date: Sun, 9 Sep 2018 08:15:20 +0000 (+0000) Subject: net: ena: fix surprise unplug NULL dereference kernel crash X-Git-Tag: Ubuntu-4.15.0-37.40~289 X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=90e2cffe00ed29da1416459feca084903888d99e;p=mirror_ubuntu-bionic-kernel.git net: ena: fix surprise unplug NULL dereference kernel crash BugLink: http://bugs.launchpad.net/bugs/1792044 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 Signed-off-by: David S. Miller (cherry picked from commit 772ed869f535b4ec2b134645c951ff22de4d3f79 linux-next) Signed-off-by: Kamal Mostafa Acked-by: Acked-by: Stefan Bader Acked-by: Brad Figg Signed-off-by: Kamal Mostafa --- diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index a822e70c2af3..4109508b6ef5 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -3434,12 +3434,12 @@ static void ena_remove(struct pci_dev *pdev) netdev->rx_cpu_rmap = NULL; } #endif /* CONFIG_RFS_ACCEL */ - - unregister_netdev(netdev); del_timer_sync(&adapter->timer_service); cancel_work_sync(&adapter->reset_task); + unregister_netdev(netdev); + /* Reset the device only if the device is running. */ if (test_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags)) ena_com_dev_reset(ena_dev, adapter->reset_reason);