]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net: ena: fix surprise unplug NULL dereference kernel crash
authorNetanel Belgazal <netanel@amazon.com>
Sun, 9 Sep 2018 08:15:20 +0000 (08:15 +0000)
committerDavid S. Miller <davem@davemloft.net>
Sun, 9 Sep 2018 14:59:55 +0000 (07:59 -0700)
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>
drivers/net/ethernet/amazon/ena/ena_netdev.c

index c673ac2df65bdf3f9b4d03403be705b581505657..170830b807fec2003592b1591e58e0c62be4b05a 100644 (file)
@@ -3409,12 +3409,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);