aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNetanel Belgazal <netanel@amazon.com>2018-09-09 04:15:24 -0400
committerDavid S. Miller <davem@davemloft.net>2018-09-09 10:59:56 -0400
commit944b28aa2982b4590d4d4dfc777cf85135dca2c0 (patch)
tree69520b05ade630919994b950735df930ade498c1
parentfe870c77efdf8682252545cbd3d29800d8379efc (diff)
net: ena: fix missing lock during device destruction
acquire the rtnl_lock during device destruction to avoid using partially destroyed device. ena_remove() shares almost the same logic as ena_destroy_device(), so use ena_destroy_device() and avoid duplications. Signed-off-by: Netanel Belgazal <netanel@amazon.com> Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r--drivers/net/ethernet/amazon/ena/ena_netdev.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c
index a68c2a8d4da2..b9ce2a6a87ed 100644
--- a/drivers/net/ethernet/amazon/ena/ena_netdev.c
+++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c
@@ -3421,24 +3421,18 @@ static void ena_remove(struct pci_dev *pdev)
3421 3421
3422 unregister_netdev(netdev); 3422 unregister_netdev(netdev);
3423 3423
3424 /* Reset the device only if the device is running. */ 3424 /* If the device is running then we want to make sure the device will be
3425 * reset to make sure no more events will be issued by the device.
3426 */
3425 if (test_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags)) 3427 if (test_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags))
3426 ena_com_dev_reset(ena_dev, adapter->reset_reason); 3428 set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
3427
3428 ena_free_mgmnt_irq(adapter);
3429 3429
3430 ena_disable_msix(adapter); 3430 rtnl_lock();
3431 ena_destroy_device(adapter, true);
3432 rtnl_unlock();
3431 3433
3432 free_netdev(netdev); 3434 free_netdev(netdev);
3433 3435
3434 ena_com_mmio_reg_read_request_destroy(ena_dev);
3435
3436 ena_com_abort_admin_commands(ena_dev);
3437
3438 ena_com_wait_for_abort_completion(ena_dev);
3439
3440 ena_com_admin_destroy(ena_dev);
3441
3442 ena_com_rss_destroy(ena_dev); 3436 ena_com_rss_destroy(ena_dev);
3443 3437
3444 ena_com_delete_debug_area(ena_dev); 3438 ena_com_delete_debug_area(ena_dev);