Skip to content

Commit 9d51db4

Browse files
etantilovgregkh
authored andcommitted
ixgbe: handle close/suspend race with netif_device_detach/present
[ Upstream commit f7f37e7ff2b9b7eff7fbd035569cab35896869a3 ] 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: Emil Tantilov <emil.s.tantilov@intel.com> Tested-by: Andrew Bowers <andrewx.bowers@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent f12976c commit 9d51db4

1 file changed

Lines changed: 8 additions & 9 deletions

File tree

drivers/net/ethernet/intel/ixgbe/ixgbe_main.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5878,7 +5878,8 @@ static int ixgbe_close(struct net_device *netdev)
58785878

58795879
ixgbe_ptp_stop(adapter);
58805880

5881-
ixgbe_close_suspend(adapter);
5881+
if (netif_device_present(netdev))
5882+
ixgbe_close_suspend(adapter);
58825883

58835884
ixgbe_fdir_filter_exit(adapter);
58845885

@@ -5923,14 +5924,12 @@ static int ixgbe_resume(struct pci_dev *pdev)
59235924
if (!err && netif_running(netdev))
59245925
err = ixgbe_open(netdev);
59255926

5926-
rtnl_unlock();
59275927

5928-
if (err)
5929-
return err;
5930-
5931-
netif_device_attach(netdev);
5928+
if (!err)
5929+
netif_device_attach(netdev);
5930+
rtnl_unlock();
59325931

5933-
return 0;
5932+
return err;
59345933
}
59355934
#endif /* CONFIG_PM */
59365935

@@ -5945,14 +5944,14 @@ static int __ixgbe_shutdown(struct pci_dev *pdev, bool *enable_wake)
59455944
int retval = 0;
59465945
#endif
59475946

5947+
rtnl_lock();
59485948
netif_device_detach(netdev);
59495949

5950-
rtnl_lock();
59515950
if (netif_running(netdev))
59525951
ixgbe_close_suspend(adapter);
5953-
rtnl_unlock();
59545952

59555953
ixgbe_clear_interrupt_scheme(adapter);
5954+
rtnl_unlock();
59565955

59575956
#ifdef CONFIG_PM
59585957
retval = pci_save_state(pdev);

0 commit comments

Comments
 (0)