From patchwork Mon Nov 28 18:24:59 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9449977 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 E19406071C for ; Mon, 28 Nov 2016 18:32:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D85FE25D97 for ; Mon, 28 Nov 2016 18:32:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CC05427F9C; Mon, 28 Nov 2016 18:32:04 +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 8AB6625D97 for ; Mon, 28 Nov 2016 18:32:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754793AbcK1S2r (ORCPT ); Mon, 28 Nov 2016 13:28:47 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:34832 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751583AbcK1S1b (ORCPT ); Mon, 28 Nov 2016 13:27:31 -0500 Received: by mail-lf0-f65.google.com with SMTP id p100so10340687lfg.2; 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=0zbZhBn/KyPwjbTLzV9sPDXpHLqdaOlqCDycGIVS3TQ=; b=dQ0A2/yMkGU++gfnF5mp1yI4w+2EEmo2LFGSwD0/oTvFeKqTY7qA+enfNl9f/NUZ6d A7ixODeWKu94drLYzxQBYEmkGLvQInGKGOwfrErkFXghUEine0zUFq1nSSiZ5fcqJpnt GM5VVh8caifKkfdBpdXFv4Hd20IqMBIZOiadoNwBS/+K2UEWgNtlNIQYxaE249cgQgbA 1h4XAegP7v7kqD+WPZNpD6DEqza1/0mYcix9S7EdccsxQ+9seDiir8aY5S/B+uSgja2d 869XSmr6byv1AfaHwdTOb2zhBDgy9xOp8VMHkJGEeDRdMTBaQk+pNczMRjKb6TAATOCq vCZQ== 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=0zbZhBn/KyPwjbTLzV9sPDXpHLqdaOlqCDycGIVS3TQ=; b=YPwC5ofztZOA+EO3NCu5e90b3oaE/+tj1StBdtFbAkF0omQTXnDvEgg3UbRv5ErHqa 7kM/fb1FlM1QwCr21XOy1GHEsuNIjD6Vwss5fyUS3/4+qh5F/31Cm0pYmEhP7QfRzg91 Lu/2KYWlXuXU9bh5iLhJX6h6QsfWwBUG0YqOlS35nOTawgkTn+10/dBAVWQX87A63hPP QWoaPU/SktRlbcg5ssVhDJEiJ9RH4MffF8r9k0PJOEnuDqkgyKhcqx1pkssdF/XPxPWo nIJ09iEpK14rmjsE/PlQ10on+7MYNVssg8c9HUe+JhL4Hw9AVB4yMRzIsOZ7V+UgKFsw MhJA== X-Gm-Message-State: AKaTC02OZxsQwrTfcoJoeDJ8bN69+2Thv70qxkkKDzwkl7PiBQz0EXr2YtsvGo1NiHG+Iw== X-Received: by 10.25.75.213 with SMTP id y204mr6940374lfa.64.1480357649178; Mon, 28 Nov 2016 10:27:29 -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 z1sm13082954lja.27.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-0007KP-AM; 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 06/16] net: ethernet: bcmgenet: fix fixed-link phydev leaks Date: Mon, 28 Nov 2016 19:24:59 +0100 Message-Id: <1480357509-28074-7-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. Note that we're still leaking any fixed-link PHY registered in the non-OF probe path. Fixes: 9abf0c2b717a ("net: bcmgenet: use the new fixed PHY helpers") Signed-off-by: Johan Hovold --- drivers/net/ethernet/broadcom/genet/bcmmii.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/net/ethernet/broadcom/genet/bcmmii.c b/drivers/net/ethernet/broadcom/genet/bcmmii.c index 2e745bd51df4..e87607621e62 100644 --- a/drivers/net/ethernet/broadcom/genet/bcmmii.c +++ b/drivers/net/ethernet/broadcom/genet/bcmmii.c @@ -627,6 +627,7 @@ static int bcmgenet_mii_bus_init(struct bcmgenet_priv *priv) int bcmgenet_mii_init(struct net_device *dev) { struct bcmgenet_priv *priv = netdev_priv(dev); + struct device_node *dn = priv->pdev->dev.of_node; int ret; ret = bcmgenet_mii_alloc(priv); @@ -640,6 +641,8 @@ int bcmgenet_mii_init(struct net_device *dev) return 0; out: + if (of_phy_is_fixed_link(dn)) + of_phy_deregister_fixed_link(dn); of_node_put(priv->phy_dn); mdiobus_unregister(priv->mii_bus); mdiobus_free(priv->mii_bus); @@ -649,7 +652,10 @@ int bcmgenet_mii_init(struct net_device *dev) void bcmgenet_mii_exit(struct net_device *dev) { struct bcmgenet_priv *priv = netdev_priv(dev); + struct device_node *dn = priv->pdev->dev.of_node; + if (of_phy_is_fixed_link(dn)) + of_phy_deregister_fixed_link(dn); of_node_put(priv->phy_dn); mdiobus_unregister(priv->mii_bus); mdiobus_free(priv->mii_bus);