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 3BBEBC282CE for ; Wed, 13 Feb 2019 02:48:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 0113E2175B for ; Wed, 13 Feb 2019 02:48:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550026089; bh=tHqfUanSKFBXC7jmBlPYykEeDrnbGfgEw8RaKA7Brlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=xkKlIF/qA1RY9W6JQ+5bCAgJD/sPQspvI7WLzoOX6MGp+i6sW4Lm9Um30MBv+3fwR kk2MENoisWbmbfhlSzkoGhJwvilYs6urGgZM+Z+Ebhag58dS0JaveooCR1SjrNhu26 r/6aaJsoMFzGf0N3jEOlFCUZwveBV/+WyVsG6F+0= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388984AbfBMCkZ (ORCPT ); Tue, 12 Feb 2019 21:40:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:44120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726921AbfBMCkY (ORCPT ); Tue, 12 Feb 2019 21:40:24 -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 4487C222C9; Wed, 13 Feb 2019 02:40:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550025623; bh=tHqfUanSKFBXC7jmBlPYykEeDrnbGfgEw8RaKA7Brlk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=O56/TLXss/ChSTRqZvmcnB9qG4kVYJgUd5szmEW9X4JaIH88lEsXIyc3UePS7OTUF tca9agGWZranpqH9DBqp1HdYNS7N8fhE9pgzj7fBPfUKXQYo8/AKuqR5q32jNpCfA+ 7g2KtpuyHGDdWVOkJmwixyk4hXhm6kH5yRrMmunc= 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.14 22/34] net: stmmac: Fix PCI module removal leak Date: Tue, 12 Feb 2019 21:39:40 -0500 Message-Id: <20190213023952.21311-22-sashal@kernel.org> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190213023952.21311-1-sashal@kernel.org> References: <20190213023952.21311-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