Commit 1954e87c authored by Netanel Belgazal's avatar Netanel Belgazal Committed by Kleber Sacilotto de Souza

net: ena: fix missing lock during device destruction

BugLink: http://bugs.launchpad.net/bugs/1792044

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: default avatarNetanel Belgazal <netanel@amazon.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
(cherry picked from commit 944b28aa linux-next)
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
Acked-by: default avatarAcked-by: Stefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarBrad Figg <brad.figg@canonical.com>
Signed-off-by: default avatarKamal Mostafa <kamal@canonical.com>
parent 5b1c2c5f
......@@ -3433,24 +3433,18 @@ static void ena_remove(struct pci_dev *pdev)
unregister_netdev(netdev);
/* Reset the device only if the device is running. */
/* If the device is running then we want to make sure the device will be
* reset to make sure no more events will be issued by the device.
*/
if (test_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags))
ena_com_dev_reset(ena_dev, adapter->reset_reason);
ena_free_mgmnt_irq(adapter);
set_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
ena_disable_msix(adapter);
rtnl_lock();
ena_destroy_device(adapter, true);
rtnl_unlock();
free_netdev(netdev);
ena_com_mmio_reg_read_request_destroy(ena_dev);
ena_com_abort_admin_commands(ena_dev);
ena_com_wait_for_abort_completion(ena_dev);
ena_com_admin_destroy(ena_dev);
ena_com_rss_destroy(ena_dev);
ena_com_delete_debug_area(ena_dev);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment