提交 a69bf3c5 编写于 作者: D Douglas Miller 提交者: David S. Miller

be2net: Don't leak iomapped memory on removal.

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: 25848c90 ("use PCI MMIO read instead of config read for errors")
Signed-off-by: NDouglas Miller <dougmill@linux.vnet.ibm.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 cec05562
...@@ -531,6 +531,7 @@ struct be_adapter { ...@@ -531,6 +531,7 @@ struct be_adapter {
struct delayed_work be_err_detection_work; struct delayed_work be_err_detection_work;
u8 err_flags; u8 err_flags;
bool pcicfg_mapped; /* pcicfg obtained via pci_iomap() */
u32 flags; u32 flags;
u32 cmd_privileges; u32 cmd_privileges;
/* Ethtool knobs and info */ /* Ethtool knobs and info */
......
...@@ -4970,6 +4970,8 @@ static void be_unmap_pci_bars(struct be_adapter *adapter) ...@@ -4970,6 +4970,8 @@ static void be_unmap_pci_bars(struct be_adapter *adapter)
pci_iounmap(adapter->pdev, adapter->csr); pci_iounmap(adapter->pdev, adapter->csr);
if (adapter->db) if (adapter->db)
pci_iounmap(adapter->pdev, 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) static int db_bar(struct be_adapter *adapter)
...@@ -5021,8 +5023,10 @@ static int be_map_pci_bars(struct be_adapter *adapter) ...@@ -5021,8 +5023,10 @@ static int be_map_pci_bars(struct be_adapter *adapter)
if (!addr) if (!addr)
goto pci_map_err; goto pci_map_err;
adapter->pcicfg = addr; adapter->pcicfg = addr;
adapter->pcicfg_mapped = true;
} else { } else {
adapter->pcicfg = adapter->db + SRIOV_VF_PCICFG_OFFSET; adapter->pcicfg = adapter->db + SRIOV_VF_PCICFG_OFFSET;
adapter->pcicfg_mapped = false;
} }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册