From patchwork Mon Nov 28 18:25:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9449917 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 246BD6071C for ; Mon, 28 Nov 2016 18:28:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 1ADFD27FBB for ; Mon, 28 Nov 2016 18:28:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0E6062807E; Mon, 28 Nov 2016 18:28:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CE85F27FB6 for ; Mon, 28 Nov 2016 18:28:27 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBQfC-0001i3-GY; Mon, 28 Nov 2016 18:28:26 +0000 Received: from mail-lf0-x243.google.com ([2a00:1450:4010:c07::243]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBQee-00015R-RG for linux-mediatek@lists.infradead.org; Mon, 28 Nov 2016 18:27:59 +0000 Received: by mail-lf0-x243.google.com with SMTP id o20so10330523lfg.3 for ; Mon, 28 Nov 2016 10:27:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=qILMaPPZkvXrJBcNCYXW3t6yWcRl+kcY0Qel3kIxRds=; b=gOnadTdxpVedFyDoNCNUAcjQRMVO10eKJWimTt8u3ghUOqIowY3nwz62Kuj13RJiQO FUlkHp6QJtxBzPOrwx5hjhWAU/PZCSOhRiLAbeeJAbyKLeRvEDxEPfkrLRymfh0gWB9g vHqsXK9txdI+Hi7MajMMq+QmcfWIf/o9VVhKjeiJuiUVngzVGU9lXKBmNxD6kf/tyCij V0UhOvEyDazq/ML0xsLBDlfknubyMH4/c1bg78OGxqlI9nLI3Tb3Y7GvmRa6MtYqLvUf kN52bphqbHUGcYdmxwoy1K5456oLKOHg6iH57cz1fwoQ+MvXHYNZXrb4f4RrMEYhO5gY O3MA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=qILMaPPZkvXrJBcNCYXW3t6yWcRl+kcY0Qel3kIxRds=; b=OFp7iUiE9rjBQm/QunCwvaUutD6ejWeNPV7WtVrxGzpM0RQ2+KE7THsmDIOWSsJWes Cw0TD6vyhZa3E/TcCcbgGjKiyXvpGi+tud8QPOs+BlfZRQBZehYsCtEz1qPMZIETHGlu klBUOlAKMNLpbAMKVqSUv2erBI0RK06bU2MoyUBxsqmWvcjk4SN0+DnDNvLx/jvkTxi5 rl5ROQ7623ytb2ooWQzZwsr7i2RTXW71abYqc0SJOEr2IoUN6PSwiW23V5M40WT7aeMK rek6NfLdM6tolyNZsrACOb/W2k/YcKsuFkwJ9oiXYlm9+SBvt7jkHJGYnvJpMGXYA758 ehaQ== X-Gm-Message-State: AKaTC03mZW8Mz8nKFNftkkAJnOyvRVFtjt5PJkdzwBY6PJbNhWmsAsYtJBaLdW8s9rkAFw== X-Received: by 10.25.17.27 with SMTP id g27mr7143569lfi.46.1480357652743; Mon, 28 Nov 2016 10:27:32 -0800 (PST) Received: from xi.terra (c-04aadb54.07-184-6d6c6d4.cust.bredbandsbolaget.se. [84.219.170.4]) by smtp.gmail.com with ESMTPSA id v17sm13032599lja.43.2016.11.28.10.27.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 10:27:30 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.87) (envelope-from ) id 1cBQeB-0007LA-23; Mon, 28 Nov 2016 19:27:23 +0100 From: Johan Hovold To: "David S. Miller" Subject: [PATCH net 15/16] net: ethernet: ti: davinci_emac: fix fixed-link phydev and of-node leaks Date: Mon, 28 Nov 2016 19:25:08 +0100 Message-Id: <1480357509-28074-16-git-send-email-johan@kernel.org> X-Mailer: git-send-email 2.7.3 In-Reply-To: <1480357509-28074-1-git-send-email-johan@kernel.org> References: <1480357509-28074-1-git-send-email-johan@kernel.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161128_102753_407880_9F990533 X-CRM114-Status: GOOD ( 12.31 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Andrew Lunn , devicetree@vger.kernel.org, Pantelis Antoniou , Frank Rowand , Felix Fietkau , Florian Fainelli , Claudiu Manoil , Li Yang , Mugunthan V N , Grygorii Strashko , linuxppc-dev@lists.ozlabs.org, Johan Hovold , Rob Herring , linux-mediatek@lists.infradead.org, Lars Persson , Matthias Brugger , linux-omap@vger.kernel.org, John Crispin , Thomas Petazzoni , Fugang Duan , Sergei Shtylyov , Vivien Didelot , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Vitaly Bordug , nios2-dev@lists.rocketboards.org, Vince Bridgers MIME-Version: 1.0 Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Make sure to deregister and free any fixed-link PHY registered using of_phy_register_fixed_link() on probe errors and on driver unbind. Also remember to put the of-node reference on probe errors. Fixes: 1bb6aa56bb38 ("net: davinci_emac: Add support for fixed-link PHY") Signed-off-by: Johan Hovold --- drivers/net/ethernet/ti/davinci_emac.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/ti/davinci_emac.c b/drivers/net/ethernet/ti/davinci_emac.c index 84fbe5714f8b..481c7bf0395b 100644 --- a/drivers/net/ethernet/ti/davinci_emac.c +++ b/drivers/net/ethernet/ti/davinci_emac.c @@ -1767,6 +1767,7 @@ static int davinci_emac_try_get_mac(struct platform_device *pdev, */ static int davinci_emac_probe(struct platform_device *pdev) { + struct device_node *np = pdev->dev.of_node; int rc = 0; struct resource *res, *res_ctrl; struct net_device *ndev; @@ -1805,7 +1806,7 @@ static int davinci_emac_probe(struct platform_device *pdev) if (!pdata) { dev_err(&pdev->dev, "no platform data\n"); rc = -ENODEV; - goto no_pdata; + goto err_free_netdev; } /* MAC addr and PHY mask , RMII enable info from platform_data */ @@ -1941,6 +1942,10 @@ static int davinci_emac_probe(struct platform_device *pdev) cpdma_chan_destroy(priv->rxchan); cpdma_ctlr_destroy(priv->dma); no_pdata: + if (of_phy_is_fixed_link(np)) + of_phy_deregister_fixed_link(np); + of_node_put(priv->phy_node); +err_free_netdev: free_netdev(ndev); return rc; } @@ -1956,6 +1961,7 @@ static int davinci_emac_remove(struct platform_device *pdev) { struct net_device *ndev = platform_get_drvdata(pdev); struct emac_priv *priv = netdev_priv(ndev); + struct device_node *np = pdev->dev.of_node; dev_notice(&ndev->dev, "DaVinci EMAC: davinci_emac_remove()\n"); @@ -1968,6 +1974,8 @@ static int davinci_emac_remove(struct platform_device *pdev) unregister_netdev(ndev); of_node_put(priv->phy_node); pm_runtime_disable(&pdev->dev); + if (of_phy_is_fixed_link(np)) + of_phy_deregister_fixed_link(np); free_netdev(ndev); return 0;