From patchwork Sat Nov 3 08:25:30 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Cochran X-Patchwork-Id: 1691381 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 9932F3FDD1 for ; Sat, 3 Nov 2012 08:27:42 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TUZ3M-0006aX-A1; Sat, 03 Nov 2012 08:26:04 +0000 Received: from mail-ea0-f177.google.com ([209.85.215.177]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TUZ35-0006WO-2l for linux-arm-kernel@lists.infradead.org; Sat, 03 Nov 2012 08:25:48 +0000 Received: by mail-ea0-f177.google.com with SMTP id n13so1647524eaa.36 for ; Sat, 03 Nov 2012 01:25:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references :in-reply-to:references; bh=wRS5vUKkuC/FjoesPk9mZZpC2WO04wczsXibcLL1ufo=; b=UzlFlfFTxsbX/cpUzVLsXlxFEvsKMFP8wEoxOPWKi/yvNw2k0C3MJHuYSCQ2iOlIss ujHThYlhvCXxioov4a0J07yYMprNwdmVV0OMY4uRr2vFmrBF6Ix33Jpz7YbWHOkre056 OgN1eS9OiH65XDHuve1s4RBGCHKlC5Id0SAiNhcHEKHhjRRVCaGYi67ILvbo74ly8QZG JOrXx6ynMmOyJmZfEyOwWWTDbYQsH20O98qWAE3WfOJonWBOzShJ4de66GXAHHdVaCCj n/jsox8Ye64k//b0If5cbkPOJi2xvRmawaV4ofWpYrk5s217Xfp+hl+oXhKcBAm8I0Ph LSrA== Received: by 10.14.193.134 with SMTP id k6mr15359098een.15.1351931145942; Sat, 03 Nov 2012 01:25:45 -0700 (PDT) Received: from localhost.localdomain (089144206008.atnat0015.highway.a1.net. [89.144.206.8]) by mx.google.com with ESMTPS id 42sm29655967eee.0.2012.11.03.01.25.43 (version=TLSv1/SSLv3 cipher=OTHER); Sat, 03 Nov 2012 01:25:45 -0700 (PDT) From: Richard Cochran To: Subject: [PATCH net-next 2/2] cpsw: fix leaking IO mappings Date: Sat, 3 Nov 2012 09:25:30 +0100 Message-Id: <1c915a7d0301355342358db8f84560417609a61c.1351930782.git.richardcochran@gmail.com> X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: In-Reply-To: References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20121103_042547_362488_07DFE538 X-CRM114-Status: GOOD ( 12.46 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.215.177 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (richardcochran[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Mugunthan V N , Vaibhav Hiremath , David Miller , linux-arm-kernel@lists.infradead.org, Cyril Chemparathy X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org The CPSW driver remaps two different IO regions, but fails to unmap them both. This patch fixes the issue by calling iounmap in the appropriate places. Signed-off-by: Richard Cochran --- drivers/net/ethernet/ti/cpsw.c | 17 ++++++++--------- 1 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 6215246..7654a62 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -1252,14 +1252,12 @@ static int __devinit cpsw_probe(struct platform_device *pdev) ret = -ENOENT; goto clean_clk_ret; } - if (!request_mem_region(priv->cpsw_res->start, resource_size(priv->cpsw_res), ndev->name)) { dev_err(priv->dev, "failed request i/o region\n"); ret = -ENXIO; goto clean_clk_ret; } - regs = ioremap(priv->cpsw_res->start, resource_size(priv->cpsw_res)); if (!regs) { dev_err(priv->dev, "unable to map i/o region\n"); @@ -1274,16 +1272,14 @@ static int __devinit cpsw_probe(struct platform_device *pdev) if (!priv->cpsw_wr_res) { dev_err(priv->dev, "error getting i/o resource\n"); ret = -ENOENT; - goto clean_clk_ret; + goto clean_iomap_ret; } - if (!request_mem_region(priv->cpsw_wr_res->start, resource_size(priv->cpsw_wr_res), ndev->name)) { dev_err(priv->dev, "failed request i/o region\n"); ret = -ENXIO; - goto clean_clk_ret; + goto clean_iomap_ret; } - regs = ioremap(priv->cpsw_wr_res->start, resource_size(priv->cpsw_wr_res)); if (!regs) { @@ -1326,7 +1322,7 @@ static int __devinit cpsw_probe(struct platform_device *pdev) if (!priv->dma) { dev_err(priv->dev, "error initializing dma\n"); ret = -ENOMEM; - goto clean_iomap_ret; + goto clean_wr_iomap_ret; } priv->txch = cpdma_chan_create(priv->dma, tx_chan_num(0), @@ -1407,11 +1403,13 @@ clean_dma_ret: cpdma_chan_destroy(priv->txch); cpdma_chan_destroy(priv->rxch); cpdma_ctlr_destroy(priv->dma); -clean_iomap_ret: - iounmap(priv->regs); +clean_wr_iomap_ret: + iounmap(priv->wr_regs); clean_cpsw_wr_iores_ret: release_mem_region(priv->cpsw_wr_res->start, resource_size(priv->cpsw_wr_res)); +clean_iomap_ret: + iounmap(priv->regs); clean_cpsw_iores_ret: release_mem_region(priv->cpsw_res->start, resource_size(priv->cpsw_res)); @@ -1442,6 +1440,7 @@ static int __devexit cpsw_remove(struct platform_device *pdev) iounmap(priv->regs); release_mem_region(priv->cpsw_res->start, resource_size(priv->cpsw_res)); + iounmap(priv->wr_regs); release_mem_region(priv->cpsw_wr_res->start, resource_size(priv->cpsw_wr_res)); pm_runtime_disable(&pdev->dev);