Commit 9d51db4c authored by Emil Tantilov's avatar Emil Tantilov Committed by Greg Kroah-Hartman

ixgbe: handle close/suspend race with netif_device_detach/present


[ Upstream commit f7f37e7f ]

When an interface is part of a namespace it is possible that
ixgbe_close() may be called while __ixgbe_shutdown() is running
which ends up in a double free WARN and/or a BUG in free_msi_irqs().

To handle this situation we extend the rtnl_lock() to protect the
call to netif_device_detach() and ixgbe_clear_interrupt_scheme()
in __ixgbe_shutdown() and check for netif_device_present()
to avoid clearing the interrupts second time in ixgbe_close();

Also extend the rtnl lock in ixgbe_resume() to netif_device_attach().
Signed-off-by: default avatarEmil Tantilov <emil.s.tantilov@intel.com>
Tested-by: default avatarAndrew Bowers <andrewx.bowers@intel.com>
Signed-off-by: default avatarJeff Kirsher <jeffrey.t.kirsher@intel.com>
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent f12976ce
...@@ -5878,7 +5878,8 @@ static int ixgbe_close(struct net_device *netdev) ...@@ -5878,7 +5878,8 @@ static int ixgbe_close(struct net_device *netdev)
ixgbe_ptp_stop(adapter); ixgbe_ptp_stop(adapter);
ixgbe_close_suspend(adapter); if (netif_device_present(netdev))
ixgbe_close_suspend(adapter);
ixgbe_fdir_filter_exit(adapter); ixgbe_fdir_filter_exit(adapter);
...@@ -5923,14 +5924,12 @@ static int ixgbe_resume(struct pci_dev *pdev) ...@@ -5923,14 +5924,12 @@ static int ixgbe_resume(struct pci_dev *pdev)
if (!err && netif_running(netdev)) if (!err && netif_running(netdev))
err = ixgbe_open(netdev); err = ixgbe_open(netdev);
rtnl_unlock();
if (err) if (!err)
return err; netif_device_attach(netdev);
rtnl_unlock();
netif_device_attach(netdev);
return 0; return err;
} }
#endif /* CONFIG_PM */ #endif /* CONFIG_PM */
...@@ -5945,14 +5944,14 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake) ...@@ -5945,14 +5944,14 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
int retval = 0; int retval = 0;
#endif #endif
rtnl_lock();
netif_device_detach(netdev); netif_device_detach(netdev);
rtnl_lock();
if (netif_running(netdev)) if (netif_running(netdev))
ixgbe_close_suspend(adapter); ixgbe_close_suspend(adapter);
rtnl_unlock();
ixgbe_clear_interrupt_scheme(adapter); ixgbe_clear_interrupt_scheme(adapter);
rtnl_unlock();
#ifdef CONFIG_PM #ifdef CONFIG_PM
retval = pci_save_state(pdev); retval = pci_save_state(pdev);
......
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