netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Aaron Brown <aaron.f.brown@intel.com>
To: davem@davemloft.net
Cc: Mitch Williams <mitch.a.williams@intel.com>,
	netdev@vger.kernel.org, gospo@redhat.com, sassmann@redhat.com,
	Aaron Brown <aaron.f.brown@intel.com>
Subject: [net-next 14/15] i40evf: fix memory leak on unused interfaces
Date: Wed, 30 Jul 2014 17:32:10 -0700	[thread overview]
Message-ID: <1406766731-4209-15-git-send-email-aaron.f.brown@intel.com> (raw)
In-Reply-To: <1406766731-4209-1-git-send-email-aaron.f.brown@intel.com>

From: Mitch Williams <mitch.a.williams@intel.com>

If the driver is loaded and then unloaded before the interface is
brought up, then it will allocate a MAC filter entry and never free it.
To fix this, on unload, run through the mac filter list and free all the
entries. We also do this during reset recovery when the driver cannot
contact the PF and needs to shut down completely.

Change-ID: I15fabd67eb4a1bfc57605a7db60d0b5d819839db
Signed-off-by: Mitch Williams <mitch.a.williams@intel.com>
Tested-by: Sibai Li <sibai.li@intel.com>
Signed-off-by: Aaron Brown <aaron.f.brown@intel.com>
---
 drivers/net/ethernet/intel/i40evf/i40evf_main.c | 24 ++++++++++++++++++++++++
 1 file changed, 24 insertions(+)

diff --git a/drivers/net/ethernet/intel/i40evf/i40evf_main.c b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
index 0c4f7baf..e5679d8 100644
--- a/drivers/net/ethernet/intel/i40evf/i40evf_main.c
+++ b/drivers/net/ethernet/intel/i40evf/i40evf_main.c
@@ -1527,6 +1527,9 @@ static void i40evf_reset_task(struct work_struct *work)
 			msleep(I40EVF_RESET_WAIT_MS);
 	}
 	if (i == I40EVF_RESET_WAIT_COUNT) {
+		struct i40evf_mac_filter *f, *ftmp;
+		struct i40evf_vlan_filter *fv, *fvtmp;
+
 		/* reset never finished */
 		dev_err(&adapter->pdev->dev, "Reset never finished (%x)\n",
 			rstat_val);
@@ -1539,6 +1542,19 @@ static void i40evf_reset_task(struct work_struct *work)
 			i40evf_free_all_tx_resources(adapter);
 			i40evf_free_all_rx_resources(adapter);
 		}
+
+		/* Delete all of the filters, both MAC and VLAN. */
+		list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list,
+					 list) {
+			list_del(&f->list);
+			kfree(f);
+		}
+		list_for_each_entry_safe(fv, fvtmp, &adapter->vlan_filter_list,
+					 list) {
+			list_del(&fv->list);
+			kfree(fv);
+		}
+
 		i40evf_free_misc_irq(adapter);
 		i40evf_reset_interrupt_capability(adapter);
 		i40evf_free_queues(adapter);
@@ -2415,6 +2431,7 @@ static void i40evf_remove(struct pci_dev *pdev)
 {
 	struct net_device *netdev = pci_get_drvdata(pdev);
 	struct i40evf_adapter *adapter = netdev_priv(netdev);
+	struct i40evf_mac_filter *f, *ftmp;
 	struct i40e_hw *hw = &adapter->hw;
 
 	cancel_delayed_work_sync(&adapter->init_task);
@@ -2446,6 +2463,13 @@ static void i40evf_remove(struct pci_dev *pdev)
 
 	i40evf_free_queues(adapter);
 	kfree(adapter->vf_res);
+	/* If we got removed before an up/down sequence, we've got a filter
+	 * hanging out there that we need to get rid of.
+	 */
+	list_for_each_entry_safe(f, ftmp, &adapter->mac_filter_list, list) {
+		list_del(&f->list);
+		kfree(f);
+	}
 
 	free_netdev(netdev);
 
-- 
1.9.3

  parent reply	other threads:[~2014-07-31  0:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-31  0:31 [net-next 00/15] Intel Wired LAN Driver Updates Aaron Brown
2014-07-31  0:31 ` [net-next 01/15] i40e: adds FCoE code to the i40e driver Aaron Brown
2014-07-31  0:31 ` [net-next 02/15] i40e: Adds FCoE related code to i40e core driver Aaron Brown
2014-07-31  0:31 ` [net-next 03/15] i40e: adds FCoE to build and updates its documentation Aaron Brown
2014-07-31  0:32 ` [net-next 04/15] i40e: expose debug_write_register request Aaron Brown
2014-07-31  0:32 ` [net-next 05/15] i40e: use correct vf_id offset for virtchnl message Aaron Brown
2014-07-31  0:32 ` [net-next 06/15] i40e: Move some variable declarations out of a loop Aaron Brown
2014-07-31 21:05   ` David Miller
2014-07-31 23:56     ` Abodunrin, Akeem G
2014-08-01  1:31       ` David Miller
2014-07-31  0:32 ` [net-next 07/15] i40e: disable local loopback on vmdq vsi Aaron Brown
2014-07-31  0:32 ` [net-next 08/15] i40evf: fix scan warning on sprintf Aaron Brown
2014-07-31  0:32 ` [net-next 09/15] i40e: Minor comment changes Aaron Brown
2014-07-31  0:32 ` [net-next 10/15] i40e: remove support for vf unicast promiscuous mode Aaron Brown
2014-07-31  0:32 ` [net-next 11/15] i40evf: future-proof vfr_stat state check Aaron Brown
2014-07-31  0:32 ` [net-next 12/15] i40evf: do not re-arm watchdog after remove Aaron Brown
2014-07-31  0:32 ` [net-next 13/15] i40evf: don't leak queue vectors Aaron Brown
2014-07-31  0:32 ` Aaron Brown [this message]
2014-07-31  0:32 ` [net-next 15/15] i40evf: Fixed guest OS panic when removing vf driver Aaron Brown

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=1406766731-4209-15-git-send-email-aaron.f.brown@intel.com \
    --to=aaron.f.brown@intel.com \
    --cc=davem@davemloft.net \
    --cc=gospo@redhat.com \
    --cc=mitch.a.williams@intel.com \
    --cc=netdev@vger.kernel.org \
    --cc=sassmann@redhat.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).