From patchwork Mon Nov 28 18:25:07 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9449995 X-Patchwork-Delegate: geert@linux-m68k.org 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 4191C6071C for ; Mon, 28 Nov 2016 18:33:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 38A7325D97 for ; Mon, 28 Nov 2016 18:33:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2BDB727F90; Mon, 28 Nov 2016 18:33:00 +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=-6.3 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C839125D97 for ; Mon, 28 Nov 2016 18:32:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754326AbcK1S2I (ORCPT ); Mon, 28 Nov 2016 13:28:08 -0500 Received: from mail-lf0-f68.google.com ([209.85.215.68]:36332 "EHLO mail-lf0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753088AbcK1S1e (ORCPT ); Mon, 28 Nov 2016 13:27:34 -0500 Received: by mail-lf0-f68.google.com with SMTP id o20so10330441lfg.3; Mon, 28 Nov 2016 10:27:32 -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=TV29d4kBZ+eXbqtsUkjtjiBKxzLRe0paSODWTS2sDJ4=; b=Dy1ohRolRRdtVpqqk5V+whKKqbpSiLf8ZOWmvYnRZrKjzWIlOEHGXHkrXd7y0mDx3H TuFedrc0KUtG97raImjT6S97vK6NoP17YSfF7aTVRhtj6Am0NN9bABiFdN4wfrXqOV4b Dahgs62bDLjQ3pkfn749uy5MDfjvWDLdSZoll/uFHyOosrrYM5uT0Yn3yaz/hj8aJmwe 1rSQQ1ms37H7QTrnJakCt0Kh6lEi2vQBXcL4qyNMy3bapadRdFE1pWl1k9xDHxtP0kIK IART/cxiaS316S9JoDaRPfl6WNDng8aJYgLfKui+C7XOto3WC7oP8E/o1JHZ8gGdJu/R 1OQA== 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=TV29d4kBZ+eXbqtsUkjtjiBKxzLRe0paSODWTS2sDJ4=; b=mh8frM0vQz6pLofLuhBAGr4u+L0jA5x0ADoKDDVnB8El8dbEnxWGv2tZr4FhmigKKv BgxkNVw0nUglCGcL9Wn2hlgW/cYWSLKH7OxH9YW6fq6uXXo+R19tWZ7PhG9Tp0KgcH7j f0frE6gmPFarFYh9hsixNwZ3sslc5Va8bdJEQ/98MsJnbb9847/d4dhy5vzOn7bQkPOY VRq7RwceZ7qgmBVXYM8I2JXYaopw4Vg2gLfw6K2Rf1ZVLZy4kackBRdisUT2loN74B4+ ox9UzmfH4mrEcFcfXDwY1hT7WrpM9Ucvh74pqPMYZzVJtJncKzXHiB5XIVlWKSjZmk/I /YOA== X-Gm-Message-State: AKaTC01bz1nBF+Z46lsgzGc2Gitto3v8AjCmGCFp1exb7/SXOLZ3Xzq7d+OhvsKPFx6jZA== X-Received: by 10.25.211.3 with SMTP id k3mr8597493lfg.133.1480357651581; Mon, 28 Nov 2016 10:27:31 -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 x10sm4178368lja.15.2016.11.28.10.27.25 (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 1cBQeA-0007L4-VP; Mon, 28 Nov 2016 19:27:23 +0100 From: Johan Hovold To: "David S. Miller" Cc: Vince Bridgers , Florian Fainelli , Fugang Duan , Pantelis Antoniou , Vitaly Bordug , Claudiu Manoil , Li Yang , Thomas Petazzoni , Felix Fietkau , John Crispin , Matthias Brugger , Sergei Shtylyov , Lars Persson , Mugunthan V N , Grygorii Strashko , Rob Herring , Frank Rowand , Andrew Lunn , Vivien Didelot , netdev@vger.kernel.org, nios2-dev@lists.rocketboards.org, linux-kernel@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-mediatek@lists.infradead.org, linux-renesas-soc@vger.kernel.org, linux-omap@vger.kernel.org, devicetree@vger.kernel.org, Johan Hovold Subject: [PATCH net 14/16] net: ethernet: dwc_eth_qos: fix fixed-link phydev leaks Date: Mon, 28 Nov 2016 19:25:07 +0100 Message-Id: <1480357509-28074-15-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> Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.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. Fixes: 077742dac2c7 ("dwc_eth_qos: Add support for Synopsys DWC Ethernet QoS") Signed-off-by: Johan Hovold --- drivers/net/ethernet/synopsys/dwc_eth_qos.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/net/ethernet/synopsys/dwc_eth_qos.c b/drivers/net/ethernet/synopsys/dwc_eth_qos.c index 4ba2421e625d..97d64bfed465 100644 --- a/drivers/net/ethernet/synopsys/dwc_eth_qos.c +++ b/drivers/net/ethernet/synopsys/dwc_eth_qos.c @@ -2881,7 +2881,7 @@ static int dwceqos_probe(struct platform_device *pdev) ret = of_get_phy_mode(lp->pdev->dev.of_node); if (ret < 0) { dev_err(&lp->pdev->dev, "error in getting phy i/f\n"); - goto err_out_clk_dis_phy; + goto err_out_deregister_fixed_link; } lp->phy_interface = ret; @@ -2889,14 +2889,14 @@ static int dwceqos_probe(struct platform_device *pdev) ret = dwceqos_mii_init(lp); if (ret) { dev_err(&lp->pdev->dev, "error in dwceqos_mii_init\n"); - goto err_out_clk_dis_phy; + goto err_out_deregister_fixed_link; } ret = dwceqos_mii_probe(ndev); if (ret != 0) { netdev_err(ndev, "mii_probe fail.\n"); ret = -ENXIO; - goto err_out_clk_dis_phy; + goto err_out_deregister_fixed_link; } dwceqos_set_umac_addr(lp, lp->ndev->dev_addr, 0); @@ -2914,7 +2914,7 @@ static int dwceqos_probe(struct platform_device *pdev) if (ret) { dev_err(&lp->pdev->dev, "Unable to retrieve DT, error %d\n", ret); - goto err_out_clk_dis_phy; + goto err_out_deregister_fixed_link; } dev_info(&lp->pdev->dev, "pdev->id %d, baseaddr 0x%08lx, irq %d\n", pdev->id, ndev->base_addr, ndev->irq); @@ -2924,7 +2924,7 @@ static int dwceqos_probe(struct platform_device *pdev) if (ret) { dev_err(&lp->pdev->dev, "Unable to request IRQ %d, error %d\n", ndev->irq, ret); - goto err_out_clk_dis_phy; + goto err_out_deregister_fixed_link; } if (netif_msg_probe(lp)) @@ -2935,11 +2935,14 @@ static int dwceqos_probe(struct platform_device *pdev) ret = register_netdev(ndev); if (ret) { dev_err(&pdev->dev, "Cannot register net device, aborting.\n"); - goto err_out_clk_dis_phy; + goto err_out_deregister_fixed_link; } return 0; +err_out_deregister_fixed_link: + if (of_phy_is_fixed_link(pdev->dev.of_node)) + of_phy_deregister_fixed_link(pdev->dev.of_node); err_out_clk_dis_phy: clk_disable_unprepare(lp->phy_ref_clk); err_out_clk_dis_aper: @@ -2959,8 +2962,11 @@ static int dwceqos_remove(struct platform_device *pdev) if (ndev) { lp = netdev_priv(ndev); - if (ndev->phydev) + if (ndev->phydev) { phy_disconnect(ndev->phydev); + if (of_phy_is_fixed_link(pdev->dev.of_node)) + of_phy_deregister_fixed_link(pdev->dev.of_node); + } mdiobus_unregister(lp->mii_bus); mdiobus_free(lp->mii_bus);