]> git.ipfire.org Git - thirdparty/kernel/stable.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)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 10 Oct 2018 06:56:01 +0000 (08:56 +0200)
[ Upstream commit 772ed869f535b4ec2b134645c951ff22de4d3f79 ]

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>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/amazon/ena/ena_netdev.c

index f2af87d70594fca1b3c42085858fb323da295506..26686a21234ec292dbe4593833e1d96c139aca5b 100644 (file)
@@ -3408,12 +3408,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);