From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 01CA6C282D7 for ; Wed, 13 Feb 2019 03:02:32 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C3C452190A for ; Wed, 13 Feb 2019 03:02:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550026951; bh=tHqfUanSKFBXC7jmBlPYykEeDrnbGfgEw8RaKA7Brlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=LRyD+bIRwMIfu7MzaRGsFbyblnIkxNC4UXXqxOnnXef68sJDYFf9eA9ooFHRCOikF Ucm/JK5FKMIgdvpFPmRs4k66PgPO5ippniyo6JK/tY5xcf0ra6pQZI0SMo+ypSClL5 FvQdBGYo3Vw1LVi+H8zvuJU53MC6z6O21mHegSJk= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2390333AbfBMDCW (ORCPT ); Tue, 12 Feb 2019 22:02:22 -0500 Received: from mail.kernel.org ([198.145.29.99]:38564 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387830AbfBMCe7 (ORCPT ); Tue, 12 Feb 2019 21:34:59 -0500 Received: from sasha-vm.mshome.net (c-73-47-72-35.hsd1.nh.comcast.net [73.47.72.35]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 5F806222C7; Wed, 13 Feb 2019 02:34:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550025298; bh=tHqfUanSKFBXC7jmBlPYykEeDrnbGfgEw8RaKA7Brlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ABv3DF4bvn6+kzxD88mSNZeiRyxP7FSpg55Y1JlUt6ElGDsPJj4okP1Db02Le8RtZ gSbL/KpVU4DLrxB/Qs8GrjiD0ZzBt5PzIankOGpsaMHdwCiCvxZpc5BQfmQlCkEo5J wCy1brL6wPnJ99WH+Ahf7aHmT1VbJms9TMEzld1Y= From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Jose Abreu , Joao Pinto , "David S . Miller" , Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , Sasha Levin , netdev@vger.kernel.org Subject: [PATCH AUTOSEL 4.20 053/105] net: stmmac: Fix PCI module removal leak Date: Tue, 12 Feb 2019 21:32:44 -0500 Message-Id: <20190213023336.19019-53-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190213023336.19019-1-sashal@kernel.org> References: <20190213023336.19019-1-sashal@kernel.org> MIME-Version: 1.0 X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Jose Abreu [ Upstream commit 6dea7e1881fd86b80da64e476ac398008daed857 ] 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. Changes from v1: - Fix build error Cc: Joao Pinto Cc: David S. Miller Cc: Giuseppe Cavallaro Cc: Alexandre Torgue Fixes: b7d0f08e9129 ("net: stmmac: Fix WoL for PCI-based setups") Signed-off-by: Jose Abreu Signed-off-by: David S. Miller Signed-off-by: Sasha Levin --- drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c index c54a50dbd5ac..d819e8eaba12 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_END; i++) { + if (pci_resource_len(pdev, i) == 0) + continue; + pcim_iounmap_regions(pdev, BIT(i)); + break; + } + pci_disable_device(pdev); } -- 2.19.1