All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH V2 0/1] be2net: Don't leak iomapped memory on removal.
@ 2016-03-04 21:36 Douglas Miller
  2016-03-04 21:36 ` [PATCH V2 1/1] " Douglas Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Douglas Miller @ 2016-03-04 21:36 UTC (permalink / raw)
  To: netdev
  Cc: sathya.perla, ajit.khaparde, padmanabh.ratnakar,
	sriharsha.basavapatna, somnath.kotur

The adapter->pcicfg resource is either mapped via pci_iomap() or
derived from adapter->db. During be_remove() this resource was ignored
and so could remain mapped after remove.
    
Add a flag to track whether adapter->pcicfg was mapped or not, then
use that flag in be_unmap_pci_bars() to unmap if required.
    
Fixes: 25848c901 ("use PCI MMIO read instead of config read for errors")
    
Signed-off-by: Douglas Miller <dougmill@linux.vnet.ibm.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH V2 1/1] be2net: Don't leak iomapped memory on removal.
  2016-03-04 21:36 [PATCH V2 0/1] be2net: Don't leak iomapped memory on removal Douglas Miller
@ 2016-03-04 21:36 ` Douglas Miller
  2016-03-07 20:38   ` David Miller
  0 siblings, 1 reply; 3+ messages in thread
From: Douglas Miller @ 2016-03-04 21:36 UTC (permalink / raw)
  To: netdev
  Cc: sathya.perla, ajit.khaparde, padmanabh.ratnakar,
	sriharsha.basavapatna, somnath.kotur

The adapter->pcicfg resource is either mapped via pci_iomap() or
derived from adapter->db. During be_remove() this resource was ignored
and so could remain mapped after remove.

Add a flag to track whether adapter->pcicfg was mapped or not, then
use that flag in be_unmap_pci_bars() to unmap if required.

Fixes: 25848c901 ("use PCI MMIO read instead of config read for errors")

Signed-off-by: Douglas Miller <dougmill@linux.vnet.ibm.com>
---
 drivers/net/ethernet/emulex/benet/be.h      |    1 +
 drivers/net/ethernet/emulex/benet/be_main.c |    4 ++++
 2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/drivers/net/ethernet/emulex/benet/be.h b/drivers/net/ethernet/emulex/benet/be.h
index cf83783..f975129 100644
--- a/drivers/net/ethernet/emulex/benet/be.h
+++ b/drivers/net/ethernet/emulex/benet/be.h
@@ -531,6 +531,7 @@ struct be_adapter {
 
 	struct delayed_work be_err_detection_work;
 	u8 err_flags;
+	bool pcicfg_mapped;	/* pcicfg obtained via pci_iomap() */
 	u32 flags;
 	u32 cmd_privileges;
 	/* Ethtool knobs and info */
diff --git a/drivers/net/ethernet/emulex/benet/be_main.c b/drivers/net/ethernet/emulex/benet/be_main.c
index f99de36..6a7260b 100644
--- a/drivers/net/ethernet/emulex/benet/be_main.c
+++ b/drivers/net/ethernet/emulex/benet/be_main.c
@@ -4968,6 +4968,8 @@ static void be_unmap_pci_bars(struct be_adapter *adapter)
 		pci_iounmap(adapter->pdev, adapter->csr);
 	if (adapter->db)
 		pci_iounmap(adapter->pdev, adapter->db);
+	if (adapter->pcicfg && adapter->pcicfg_mapped)
+		pci_iounmap(adapter->pdev, adapter->pcicfg);
 }
 
 static int db_bar(struct be_adapter *adapter)
@@ -5019,8 +5021,10 @@ static int be_map_pci_bars(struct be_adapter *adapter)
 			if (!addr)
 				goto pci_map_err;
 			adapter->pcicfg = addr;
+			adapter->pcicfg_mapped = true;
 		} else {
 			adapter->pcicfg = adapter->db + SRIOV_VF_PCICFG_OFFSET;
+			adapter->pcicfg_mapped = false;
 		}
 	}
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH V2 1/1] be2net: Don't leak iomapped memory on removal.
  2016-03-04 21:36 ` [PATCH V2 1/1] " Douglas Miller
@ 2016-03-07 20:38   ` David Miller
  0 siblings, 0 replies; 3+ messages in thread
From: David Miller @ 2016-03-07 20:38 UTC (permalink / raw)
  To: dougmill
  Cc: netdev, sathya.perla, ajit.khaparde, padmanabh.ratnakar,
	sriharsha.basavapatna, somnath.kotur

From: Douglas Miller <dougmill@linux.vnet.ibm.com>
Date: Fri,  4 Mar 2016 15:36:56 -0600

> The adapter->pcicfg resource is either mapped via pci_iomap() or
> derived from adapter->db. During be_remove() this resource was ignored
> and so could remain mapped after remove.
> 
> Add a flag to track whether adapter->pcicfg was mapped or not, then
> use that flag in be_unmap_pci_bars() to unmap if required.
> 
> Fixes: 25848c901 ("use PCI MMIO read instead of config read for errors")
> 
> Signed-off-by: Douglas Miller <dougmill@linux.vnet.ibm.com>

Applied.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-03-07 20:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-03-04 21:36 [PATCH V2 0/1] be2net: Don't leak iomapped memory on removal Douglas Miller
2016-03-04 21:36 ` [PATCH V2 1/1] " Douglas Miller
2016-03-07 20:38   ` David Miller

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.