Skip to content

Commit bb9e44d

Browse files
bwallanJeff Kirsher
authored andcommitted
e1000e: prevent oops when adapter is being closed and reset simultaneously
When the adapter is closed while it is simultaneously going through a reset, it can cause a null-pointer dereference when the two different code paths simultaneously cleanup up the Tx/Rx resources. Signed-off-by: Bruce Allan <bruce.w.allan@intel.com> Tested-by: Aaron Brown <aaron.f.brown@intel.com> Signed-off-by: Jeff Kirsher <jeffrey.t.kirsher@intel.com>
1 parent aacc1be commit bb9e44d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

drivers/net/ethernet/intel/e1000e/e1000.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,6 +161,12 @@ struct e1000_info;
161161
/* Time to wait before putting the device into D3 if there's no link (in ms). */
162162
#define LINK_TIMEOUT 100
163163

164+
/*
165+
* Count for polling __E1000_RESET condition every 10-20msec.
166+
* Experimentation has shown the reset can take approximately 210msec.
167+
*/
168+
#define E1000_CHECK_RESET_COUNT 25
169+
164170
#define DEFAULT_RDTR 0
165171
#define DEFAULT_RADV 8
166172
#define BURST_RDTR 0x20

drivers/net/ethernet/intel/e1000e/netdev.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3968,6 +3968,10 @@ static int e1000_close(struct net_device *netdev)
39683968
{
39693969
struct e1000_adapter *adapter = netdev_priv(netdev);
39703970
struct pci_dev *pdev = adapter->pdev;
3971+
int count = E1000_CHECK_RESET_COUNT;
3972+
3973+
while (test_bit(__E1000_RESETTING, &adapter->state) && count--)
3974+
usleep_range(10000, 20000);
39713975

39723976
WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
39733977

@@ -5472,6 +5476,11 @@ static int __e1000_shutdown(struct pci_dev *pdev, bool *enable_wake,
54725476
netif_device_detach(netdev);
54735477

54745478
if (netif_running(netdev)) {
5479+
int count = E1000_CHECK_RESET_COUNT;
5480+
5481+
while (test_bit(__E1000_RESETTING, &adapter->state) && count--)
5482+
usleep_range(10000, 20000);
5483+
54755484
WARN_ON(test_bit(__E1000_RESETTING, &adapter->state));
54765485
e1000e_down(adapter);
54775486
e1000_free_irq(adapter);

0 commit comments

Comments
 (0)