Skip to content

Commit

Permalink
net: ena: fix potential double ena_destroy_device()
Browse files Browse the repository at this point in the history
ena_destroy_device() can potentially be called twice.
To avoid this, check that the device is running and
only then proceed destroying it.

Signed-off-by: Netanel Belgazal <netanel@amazon.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Netanel Belgazal authored and David S. Miller committed Sep 9, 2018
1 parent cfa324a commit fe870c7
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions drivers/net/ethernet/amazon/ena/ena_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2556,6 +2556,9 @@ static void ena_destroy_device(struct ena_adapter *adapter, bool graceful)
struct ena_com_dev *ena_dev = adapter->ena_dev;
bool dev_up;

if (!test_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags))
return;

netif_carrier_off(netdev);

del_timer_sync(&adapter->timer_service);
Expand Down Expand Up @@ -2592,6 +2595,7 @@ static void ena_destroy_device(struct ena_adapter *adapter, bool graceful)
adapter->reset_reason = ENA_REGS_RESET_NORMAL;

clear_bit(ENA_FLAG_TRIGGER_RESET, &adapter->flags);
clear_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags);
}

static int ena_restore_device(struct ena_adapter *adapter)
Expand Down Expand Up @@ -2636,6 +2640,7 @@ static int ena_restore_device(struct ena_adapter *adapter)
}
}

set_bit(ENA_FLAG_DEVICE_RUNNING, &adapter->flags);
mod_timer(&adapter->timer_service, round_jiffies(jiffies + HZ));
dev_err(&pdev->dev, "Device reset completed successfully\n");

Expand Down

0 comments on commit fe870c7

Please sign in to comment.