diff mbox series

[net,1/5] net: stmmac: Fix PCI module removal leak

Message ID c6550ba6039d127119634fe0a9bfcd08915b6c51.1546958941.git.joabreu@synopsys.com
State Superseded
Delegated to: David Miller
Headers show
Series net: stmmac: Misc fixes | expand

Commit Message

Jose Abreu Jan. 8, 2019, 2:51 p.m. UTC
Since commit b7d0f08e9129, the enable / disable of PCI device is not
managed which will result in IO regions not being automatically unmapped.
As regions continue mapped it is currently not possible to remove and
then probe again the PCI module of stmmac.

Fix this by manually unmapping regions on remove callback.

Cc: Joao Pinto <jpinto@synopsys.com>
Cc: David S. Miller <davem@davemloft.net>
Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com>
Cc: Alexandre Torgue <alexandre.torgue@st.com>
Fixes: b7d0f08e9129 ("net: stmmac: Fix WoL for PCI-based setups")
Signed-off-by: Jose Abreu <joabreu@synopsys.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

kernel test robot Jan. 9, 2019, 1:43 a.m. UTC | #1
Hi Jose,

I love your patch! Yet something to improve:

[auto build test ERROR on net/master]

url:    https://github.com/0day-ci/linux/commits/Jose-Abreu/net-stmmac-Misc-fixes/20190109-071238
config: i386-allmodconfig (attached as .config)
compiler: gcc-7 (Debian 7.3.0-1) 7.3.0
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All errors (new ones prefixed by >>):

   drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c: In function 'stmmac_pci_remove':
>> drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:306:19: error: 'PCI_STD_RESOURCE_LEN' undeclared (first use in this function); did you mean 'PCI_STD_RESOURCE_END'?
     for (i = 0; i <= PCI_STD_RESOURCE_LEN; i++) {
                      ^~~~~~~~~~~~~~~~~~~~
                      PCI_STD_RESOURCE_END
   drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c:306:19: note: each undeclared identifier is reported only once for each function it appears in

vim +306 drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c

   292	
   293	/**
   294	 * stmmac_pci_remove
   295	 *
   296	 * @pdev: platform device pointer
   297	 * Description: this function calls the main to free the net resources
   298	 * and releases the PCI resources.
   299	 */
   300	static void stmmac_pci_remove(struct pci_dev *pdev)
   301	{
   302		int i;
   303	
   304		stmmac_dvr_remove(&pdev->dev);
   305	
 > 306		for (i = 0; i <= PCI_STD_RESOURCE_LEN; i++) {
   307			if (pci_resource_len(pdev, i) == 0)
   308				continue;
   309			pcim_iounmap_regions(pdev, BIT(i));
   310			break;
   311		}
   312	
   313		pci_disable_device(pdev);
   314	}
   315	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
index c54a50dbd5ac..9d58c7cb243c 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c
@@ -299,7 +299,17 @@  static int stmmac_pci_probe(struct pci_dev *pdev,
  */
 static void stmmac_pci_remove(struct pci_dev *pdev)
 {
+	int i;
+
 	stmmac_dvr_remove(&pdev->dev);
+
+	for (i = 0; i <= PCI_STD_RESOURCE_LEN; i++) {
+		if (pci_resource_len(pdev, i) == 0)
+			continue;
+		pcim_iounmap_regions(pdev, BIT(i));
+		break;
+	}
+
 	pci_disable_device(pdev);
 }