From patchwork Mon Nov 28 18:25:00 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9449901 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 4668C6071C for ; Mon, 28 Nov 2016 18:28:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3CCE227F9C for ; Mon, 28 Nov 2016 18:28:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3156427FB6; Mon, 28 Nov 2016 18:28:17 +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 E694627F9C for ; Mon, 28 Nov 2016 18:28:16 +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 1cBQf2-0001ag-C7; Mon, 28 Nov 2016 18:28:16 +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 1cBQea-00014h-9C for linux-mediatek@lists.infradead.org; Mon, 28 Nov 2016 18:27:54 +0000 Received: by mail-lf0-x243.google.com with SMTP id o141so10369169lff.1 for ; Mon, 28 Nov 2016 10:27:31 -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=qOMPvIiKmptOndMFwVFx8+jeBJ5XOy4ganQoyzT/Heg=; b=DX253rlRSZGdvfMR+GBquKgic3Ih40/dlZQrYgDNgkCIM2TsGT+GMJ86FctaD0a8kz VHbomkd7cDyKfzXz3TDsxe9U/7So3EMgPGsNCiHlE6kfK9dpC30qFRxQjeHh3/rmvnzC dlrN+ZunT8Szp3Cp9yTALde5/5fdTwZ8w25U+Ytc3dz6ZerzSEThj36O0RvwJHjDv4IY FnP5KCbX64wx426QffLQNmlTbrocWy6A72LI0n5zQYMusokw66eJR27haPtijwklEiGf LBPdGsnYJxniEeQRUF/wCvC9ao85SqD3AfHgzXNJ11nMR/+l3zMTYCEVCeRxukHXW06e HpoA== 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=qOMPvIiKmptOndMFwVFx8+jeBJ5XOy4ganQoyzT/Heg=; b=kJgCytMi7TMuIOpwoE01+tlAdL6SQzNgnPmU9/7tscXZuPm0xv521Pp5FeNsFQHI94 KLziAcWZWq1h3IhwbxVCYFlphuIo0NeeWEIfooI8D7Pr1cgMJfDlHr7FyFiAuLDCAbG0 jEc51yPk+om9QAm3sJTcMWbqmxOhz+w45uz/FDnHm5R7V9YIMKQYE/SW63h0gOraWx5H Lj/hgW0qg7VXImMs7jGH5IJB0TxRxnJtiP4yURsXAeWCm118EbHBjg05jWlqdMCbqhPN J1DJynu3pnYxNtY065237COnpDqkJRz3lkCm/6AMaUg24om+AWBOqmjDWRWrVF3AtnAn U9NA== X-Gm-Message-State: AKaTC03yfCAJxyQlrdw6U0GjfGrNdRcC2LSE9m0I1Q0tUOLpXaIQ0wJrmO/mzYfwqGza1w== X-Received: by 10.25.219.69 with SMTP id s66mr7202485lfg.116.1480357650017; Mon, 28 Nov 2016 10:27:30 -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 u204sm12876668lja.5.2016.11.28.10.27.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 10:27:27 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.87) (envelope-from ) id 1cBQeA-0007KU-Cc; Mon, 28 Nov 2016 19:27:22 +0100 From: Johan Hovold To: "David S. Miller" Subject: [PATCH net 07/16] net: ethernet: fec: fix fixed-link phydev leaks Date: Mon, 28 Nov 2016 19:25:00 +0100 Message-Id: <1480357509-28074-8-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_102748_788032_59099C0A X-CRM114-Status: UNSURE ( 8.89 ) X-CRM114-Notice: Please train this message. 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: 407066f8f371 ("net: fec: Support phys probed from devicetree and fixed-link") Signed-off-by: Johan Hovold --- drivers/net/ethernet/freescale/fec_main.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/net/ethernet/freescale/fec_main.c b/drivers/net/ethernet/freescale/fec_main.c index 5aa9d4ded214..74dcdf097348 100644 --- a/drivers/net/ethernet/freescale/fec_main.c +++ b/drivers/net/ethernet/freescale/fec_main.c @@ -3475,6 +3475,8 @@ fec_probe(struct platform_device *pdev) failed_clk_ipg: fec_enet_clk_enable(ndev, false); failed_clk: + if (of_phy_is_fixed_link(np)) + of_phy_deregister_fixed_link(np); failed_phy: of_node_put(phy_node); failed_ioremap: @@ -3488,6 +3490,7 @@ fec_drv_remove(struct platform_device *pdev) { struct net_device *ndev = platform_get_drvdata(pdev); struct fec_enet_private *fep = netdev_priv(ndev); + struct device_node *np = pdev->dev.of_node; cancel_work_sync(&fep->tx_timeout_work); fec_ptp_stop(pdev); @@ -3495,6 +3498,8 @@ fec_drv_remove(struct platform_device *pdev) fec_enet_mii_remove(fep); if (fep->reg_phy) regulator_disable(fep->reg_phy); + if (of_phy_is_fixed_link(np)) + of_phy_deregister_fixed_link(np); of_node_put(fep->phy_node); free_netdev(ndev);