From patchwork Mon Nov 28 18:24:57 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9449881 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 BA93F6071C for ; Mon, 28 Nov 2016 18:28:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B0B2227FB3 for ; Mon, 28 Nov 2016 18:28:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A52B727FB7; Mon, 28 Nov 2016 18:28:11 +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 4C99127F9C for ; Mon, 28 Nov 2016 18:28:11 +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 1cBQew-0001Xl-EI; Mon, 28 Nov 2016 18:28:10 +0000 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBQeV-00013H-Ob for linux-mediatek@lists.infradead.org; Mon, 28 Nov 2016 18:27:46 +0000 Received: by mail-lf0-x241.google.com with SMTP id p100so10340497lfg.2 for ; Mon, 28 Nov 2016 10:27:27 -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=mfo6c1AjKv19SRvILKUhu4iOeTzOTgtkexFA8v8WZ+U=; b=bSN8mbCvl9NqQ7zSHpqeksCl8zp9y4vNRZdqldsPSohEgYcAdjQe2m6W2g3/eoPk+n 1piXvOAtbA+3kz2MQfo6ayOo4RxP0brkkCWURKPD2dmHC71w7YtXlMClAZ5up/e2BACN GFs4gP+KLzgvGE+lzROcAmuPMu+aBWgGS+qZVJh2STzfiWDnRuZSkSMC6vXEA0ejwZff y41+luuYDAagvgE4YeCPMPIeEat4BhYmU+boM+a/HPXA27Tnrq2MwWyg+bJipR+Ix6Im /beHfmBJAL+Yp8quyjRElUh9YKlHIdCB7BKzh/UzofDPuU2BDQuus+o9g1xxGOo+njAM HBAA== 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=mfo6c1AjKv19SRvILKUhu4iOeTzOTgtkexFA8v8WZ+U=; b=Yvl7vtKvXiRxC7/MKtVYMAKpqTWx29JrRxaWP3+6wlNXH39WKzc01Ht5YCe4eBnh9K 27w9G1BUL3rJgN6rUgwRuB1qZaGXhD2vRmg0VCeCIjLK0wwMzYIGoRgZ31jp1KyYKYXr SaI3MgJy8TRjnoHwFSK2PVDPbdYnoJXgeo68iOOxXlEoFmD4u0XOLzhcEbSVSxv/t+5n WOKdFJAQhcctmocd+wlGUcJbvAwSmvmyMAfaNfHOWLdF4IOo0OufXFmmgXyMAtt/ZfbV HsK0uCDgdzwsweWwwRBRcKNwjQyNTuBiGHlf+I7vrABHW1jF6rhVeayllAjMfTsq/vxt E1Ew== X-Gm-Message-State: AKaTC02I/8WWB5/2Yqx8K9fjVSKg7jWqVzRKu9OZk5vaCEf60kW/Eo/c7nnN1tnXNIwudw== X-Received: by 10.25.92.131 with SMTP id u3mr8862232lfi.15.1480357646223; Mon, 28 Nov 2016 10:27:26 -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 s189sm13138163lja.3.2016.11.28.10.27.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 10:27:26 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.87) (envelope-from ) id 1cBQeA-0007KF-5k; Mon, 28 Nov 2016 19:27:22 +0100 From: Johan Hovold To: "David S. Miller" Subject: [PATCH net 04/16] net: ethernet: aurora: nb8800: fix fixed-link phydev leaks Date: Mon, 28 Nov 2016 19:24:57 +0100 Message-Id: <1480357509-28074-5-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_102744_361218_D6083FDF X-CRM114-Status: GOOD ( 10.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. Fixes: c7dfe3abf40e ("net: ethernet: nb8800: support fixed-link DT node") Signed-off-by: Johan Hovold --- drivers/net/ethernet/aurora/nb8800.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/aurora/nb8800.c b/drivers/net/ethernet/aurora/nb8800.c index 00c38bf151e6..e078d8da978c 100644 --- a/drivers/net/ethernet/aurora/nb8800.c +++ b/drivers/net/ethernet/aurora/nb8800.c @@ -1466,12 +1466,12 @@ static int nb8800_probe(struct platform_device *pdev) ret = nb8800_hw_init(dev); if (ret) - goto err_free_bus; + goto err_deregister_fixed_link; if (ops && ops->init) { ret = ops->init(dev); if (ret) - goto err_free_bus; + goto err_deregister_fixed_link; } dev->netdev_ops = &nb8800_netdev_ops; @@ -1504,6 +1504,9 @@ static int nb8800_probe(struct platform_device *pdev) err_free_dma: nb8800_dma_free(dev); +err_deregister_fixed_link: + if (of_phy_is_fixed_link(pdev->dev.of_node)) + of_phy_deregister_fixed_link(pdev->dev.of_node); err_free_bus: of_node_put(priv->phy_node); mdiobus_unregister(bus); @@ -1521,6 +1524,8 @@ static int nb8800_remove(struct platform_device *pdev) struct nb8800_priv *priv = netdev_priv(ndev); unregister_netdev(ndev); + if (of_phy_is_fixed_link(pdev->dev.of_node)) + of_phy_deregister_fixed_link(pdev->dev.of_node); of_node_put(priv->phy_node); mdiobus_unregister(priv->mii_bus);