public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: <netanel@amazon•com>
To: <davem@davemloft•net>, <netdev@vger•kernel.org>
Cc: Netanel Belgazal <netanel@amazon•com>, <dwmw@amazon•com>,
	<zorik@amazon•com>, <matua@amazon•com>, <saeedb@amazon•com>,
	<msw@amazon•com>, <aliguori@amazon•com>, <nafea@amazon•com>,
	<evgenys@amazon•com>, <gtzalik@amazon•com>
Subject: [PATCH net V2 4/7] net: ena: fix potential double ena_destroy_device()
Date: Sun, 9 Sep 2018 08:15:23 +0000	[thread overview]
Message-ID: <20180909081526.83979-5-netanel@amazon.com> (raw)
In-Reply-To: <20180909081526.83979-1-netanel@amazon.com>

From: Netanel Belgazal <netanel@amazon•com>

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>
---
 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

  parent reply	other threads:[~2018-09-09 13:04 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-09  8:15 [PATCH net V2 0/7] bug fixes for ENA Ethernet driver netanel
2018-09-09  8:15 ` [PATCH net V2 1/7] net: ena: fix surprise unplug NULL dereference kernel crash netanel
2018-09-09  8:15 ` [PATCH net V2 2/7] net: ena: fix driver when PAGE_SIZE == 64kB netanel
2018-09-09  8:15 ` [PATCH net V2 3/7] net: ena: fix device destruction to gracefully free resources netanel
2018-09-09  8:15 ` netanel [this message]
2018-09-09  8:15 ` [PATCH net V2 5/7] net: ena: fix missing lock during device destruction netanel
2018-09-09  8:15 ` [PATCH net V2 6/7] net: ena: fix missing calls to READ_ONCE netanel
2018-09-09  8:15 ` [PATCH net V2 7/7] net: ena: fix incorrect usage of memory barriers netanel
2018-09-09 16:41 ` [PATCH net V2 0/7] bug fixes for ENA Ethernet driver David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180909081526.83979-5-netanel@amazon.com \
    --to=netanel@amazon$(echo .)com \
    --cc=aliguori@amazon$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=dwmw@amazon$(echo .)com \
    --cc=evgenys@amazon$(echo .)com \
    --cc=gtzalik@amazon$(echo .)com \
    --cc=matua@amazon$(echo .)com \
    --cc=msw@amazon$(echo .)com \
    --cc=nafea@amazon$(echo .)com \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=saeedb@amazon$(echo .)com \
    --cc=zorik@amazon$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox