From: Emil Tantilov <emil.s.tantilov@intel.com>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH v3] ixgbevf: handle race between close and suspend on shutdown
Date: Tue, 08 Nov 2016 12:18:00 -0800 [thread overview]
Message-ID: <20161108201800.10886.90964.stgit@localhost6.localdomain6> (raw)
When an interface is part of a namespace it is possible that
ixgbevf_close() may be called while ixgbevf_suspend() is running
which ends up in a double free WARN and/or a BUG in free_msi_irqs()
To handle this situation we extend the rtnl_lock() to protect the
call to netif_device_detach() and check for !netif_device_present()
to avoid entering close while in suspend.
Also added rtnl locks to ixgbevf_queue_reset_subtask().
-v2 handle the race with netif_device_detach/present() and rtnl
locks as suggested by Alex Duyck
-v3 add rtnl locks and check in ixgbevf_remove()
CC: Alexander Duyck <alexander.h.duyck@intel.com>
Signed-off-by: Emil Tantilov <emil.s.tantilov@intel.com>
---
drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c | 19 +++++++++++++++----
1 file changed, 15 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
index d316f50..eac594c 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ixgbevf_main.c
@@ -3242,6 +3242,9 @@ int ixgbevf_close(struct net_device *netdev)
{
struct ixgbevf_adapter *adapter = netdev_priv(netdev);
+ if (!netif_device_present(netdev))
+ return 0;
+
ixgbevf_down(adapter);
ixgbevf_free_irq(adapter);
@@ -3268,6 +3271,8 @@ static void ixgbevf_queue_reset_subtask(struct ixgbevf_adapter *adapter)
* match packet buffer alignment. Unfortunately, the
* hardware is not flexible enough to do this dynamically.
*/
+ rtnl_lock();
+
if (netif_running(dev))
ixgbevf_close(dev);
@@ -3276,6 +3281,8 @@ static void ixgbevf_queue_reset_subtask(struct ixgbevf_adapter *adapter)
if (netif_running(dev))
ixgbevf_open(dev);
+
+ rtnl_unlock();
}
static void ixgbevf_tx_ctxtdesc(struct ixgbevf_ring *tx_ring,
@@ -3792,17 +3799,17 @@ static int ixgbevf_suspend(struct pci_dev *pdev, pm_message_t state)
int retval = 0;
#endif
+ rtnl_lock();
netif_device_detach(netdev);
if (netif_running(netdev)) {
- rtnl_lock();
ixgbevf_down(adapter);
ixgbevf_free_irq(adapter);
ixgbevf_free_all_tx_resources(adapter);
ixgbevf_free_all_rx_resources(adapter);
ixgbevf_clear_interrupt_scheme(adapter);
- rtnl_unlock();
}
+ rtnl_unlock();
#ifdef CONFIG_PM
retval = pci_save_state(pdev);
@@ -4199,8 +4206,12 @@ static void ixgbevf_remove(struct pci_dev *pdev)
if (netdev->reg_state == NETREG_REGISTERED)
unregister_netdev(netdev);
- ixgbevf_clear_interrupt_scheme(adapter);
- ixgbevf_reset_interrupt_capability(adapter);
+ rtnl_lock();
+ if (netif_device_present(netdev)) {
+ ixgbevf_clear_interrupt_scheme(adapter);
+ ixgbevf_reset_interrupt_capability(adapter);
+ }
+ rtnl_unlock();
iounmap(adapter->io_addr);
pci_release_regions(pdev);
next reply other threads:[~2016-11-08 20:18 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-11-08 20:18 Emil Tantilov [this message]
2016-11-09 3:23 ` [Intel-wired-lan] [PATCH v3] ixgbevf: handle race between close and suspend on shutdown Alexander Duyck
2016-11-09 6:41 ` Tantilov, Emil S
2016-11-09 7:09 ` Alexander Duyck
2016-11-09 20:43 ` Tantilov, Emil S
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=20161108201800.10886.90964.stgit@localhost6.localdomain6 \
--to=emil.s.tantilov@intel.com \
--cc=intel-wired-lan@osuosl.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.