From mboxrd@z Thu Jan 1 00:00:00 1970 From: Subject: [PATCH net V2 4/7] net: ena: fix potential double ena_destroy_device() Date: Sun, 9 Sep 2018 08:15:23 +0000 Message-ID: <20180909081526.83979-5-netanel@amazon.com> References: <20180909081526.83979-1-netanel@amazon.com> Mime-Version: 1.0 Content-Type: text/plain Cc: Netanel Belgazal , , , , , , , , , To: , Return-path: Received: from smtp-fw-6001.amazon.com ([52.95.48.154]:43688 "EHLO smtp-fw-6001.amazon.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726489AbeIINEf (ORCPT ); Sun, 9 Sep 2018 09:04:35 -0400 In-Reply-To: <20180909081526.83979-1-netanel@amazon.com> Sender: netdev-owner@vger.kernel.org List-ID: From: Netanel Belgazal 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 --- drivers/net/ethernet/amazon/ena/ena_netdev.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/amazon/ena/ena_netdev.c b/drivers/net/ethernet/amazon/ena/ena_netdev.c index 035d47d2179a..a68c2a8d4da2 100644 --- a/drivers/net/ethernet/amazon/ena/ena_netdev.c +++ b/drivers/net/ethernet/amazon/ena/ena_netdev.c @@ -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); @@ -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) @@ -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"); -- 2.15.2.AMZN