Skip to content

Commit 9474933

Browse files
Todd FujinakaJeff Kirsher
authored andcommitted
igb: close/suspend race in netif_device_detach
Similar to ixgbe, when an interface is part of a namespace it is possible that igb_close() may be called while __igb_shutdown() is running which ends up in a double free WARN and/or a BUG in free_msi_irqs(). Extend the rtnl_lock() to protect the call to netif_device_detach() and igb_clear_interrupt_scheme() in __igb_shutdown() and check for netif_device_present() to avoid calling igb_clear_interrupt_scheme() a second time in igb_close(). Also extend the rtnl lock in igb_resume() to netif_device_attach(). Signed-off-by: Todd Fujinaka <todd.fujinaka@intel.com> Acked-by: Alexander Duyck <alexander.h.duyck@intel.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
1 parent 69b97cf commit 9474933

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

‎drivers/net/ethernet/intel/igb/igb_main.c‎

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3275,7 +3275,9 @@ static int __igb_close(struct net_device *netdev, bool suspending)
32753275

32763276
int igb_close(struct net_device *netdev)
32773277
{
3278-
return __igb_close(netdev, false);
3278+
if (netif_device_present(netdev))
3279+
return __igb_close(netdev, false);
3280+
return 0;
32793281
}
32803282

32813283
/**
@@ -7564,6 +7566,7 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
75647566
int retval = 0;
75657567
#endif
75667568

7569+
rtnl_lock();
75677570
netif_device_detach(netdev);
75687571

75697572
if (netif_running(netdev))
@@ -7572,6 +7575,7 @@ static int __igb_shutdown(struct pci_dev *pdev, bool *enable_wake,
75727575
igb_ptp_suspend(adapter);
75737576

75747577
igb_clear_interrupt_scheme(adapter);
7578+
rtnl_unlock();
75757579

75767580
#ifdef CONFIG_PM
75777581
retval = pci_save_state(pdev);
@@ -7690,16 +7694,15 @@ static int igb_resume(struct device *dev)
76907694

76917695
wr32(E1000_WUS, ~0);
76927696

7693-
if (netdev->flags & IFF_UP) {
7694-
rtnl_lock();
7697+
rtnl_lock();
7698+
if (!err && netif_running(netdev))
76957699
err = __igb_open(netdev, true);
7696-
rtnl_unlock();
7697-
if (err)
7698-
return err;
7699-
}
77007700

7701-
netif_device_attach(netdev);
7702-
return 0;
7701+
if (!err)
7702+
netif_device_attach(netdev);
7703+
rtnl_unlock();
7704+
7705+
return err;
77037706
}
77047707

77057708
static int igb_runtime_idle(struct device *dev)

0 commit comments

Comments
 (0)