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: 9449897 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 34A3B6071C for ; Mon, 28 Nov 2016 18:28:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2896027FB3 for ; Mon, 28 Nov 2016 18:28:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1CF4427FBB; Mon, 28 Nov 2016 18:28:15 +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 CE98B27FB3 for ; Mon, 28 Nov 2016 18:28:14 +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 1cBQf0-0001ZC-1Z; Mon, 28 Nov 2016 18:28:14 +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-00014T-9Q for linux-mediatek@lists.infradead.org; Mon, 28 Nov 2016 18:27:50 +0000 Received: by mail-lf0-x243.google.com with SMTP id o141so10369108lff.1 for ; 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=F5WIWC9AaQeNVwrhq18FpGksMyXhPNo1+jzBUY3yLmrOqj4WymAUT0NlXfvnl6AR4f 3g27csTfNwCUuGQ8fha17vM6iR22Q9NciXdjFahwpLJGrw0J7YBlxAHEZVZtpKE0hJPB NrKF90mlVIF5btcQc9p/xf4SZsY203h18a2Ar9tcsCqjGwR+0rn1TvnWHalOy16KYhtw 083ZR27mdZ083GvuO9R22RwyzxHRxJnjXu5yytJSNlYiqz2lLncjw30NkBlgGULt9zwy Q69FMaOTmrr3As0a3ICPXaoxin89g2NXklqcO/AKViX+iHLSTh5GDtzT5UhSf2yTNhFV aKGA== X-Gm-Message-State: AKaTC03aY25RDb+ZfwsRkdz12E/QOspe+8GG28wN8UR6k88pMNDgFUAjbSh/FZVit7u+Sw== 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" 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161128_102748_800741_C50A2CF8 X-CRM114-Status: UNSURE ( 9.53 ) 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. 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);