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: 9449983 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 331F46071C for ; Mon, 28 Nov 2016 18:32:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 28C8425D97 for ; Mon, 28 Nov 2016 18:32:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CD9D27D5E; Mon, 28 Nov 2016 18:32:18 +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 CC29925D97 for ; Mon, 28 Nov 2016 18:32:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754650AbcK1S2f (ORCPT ); Mon, 28 Nov 2016 13:28:35 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:33750 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752169AbcK1S1c (ORCPT ); Mon, 28 Nov 2016 13:27:32 -0500 Received: by mail-lf0-f65.google.com with SMTP id 98so10306045lfs.0; Mon, 28 Nov 2016 10:27:30 -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=f8hTQI8GjRF1ARlT8THaxn0/MzHMaU6uyZJU5MtzHWvV7fTgphksCqFXHihHdbLxgl 7XNMCNQxYdzAf6devGFmm14TRx5xojMiwF5yw0Ea9FPo3CTYazc4g0PWeXxJzX6EpW8m G/QIaiLkanByw0gqhZn8/dCQBX7AZ17Zb5ZbkIzy81h25J6Dcxt8xcOKRzc7XQ54tllp 5OB7qv1W8VAKKKI84m6iVs/CvStoKzBhs9FGfaKuQovjDBpaGpCpW3RonVCQtF5eQaC6 p/Kr275tG+0Hvn+cz6HEetiE4NCx/OfTQ3l8CZVYY/Zq3CK3AK+6QFz2xFACgcnvqd1Z KnIg== X-Gm-Message-State: AKaTC02vSBdFjWkQBs0QkpYgPHY82j9/A159fRCENP4yRwuofu2VHApfiy8k8src9Hx7HQ== 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" 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 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> 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: 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);