From patchwork Mon Nov 28 18:25:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9449973 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 7D84E6071C 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 74F5425D97 for ; Mon, 28 Nov 2016 18:32:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6938427F90; 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 1D9B525D97 for ; Mon, 28 Nov 2016 18:32:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754826AbcK1S2v (ORCPT ); Mon, 28 Nov 2016 13:28:51 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:33742 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751532AbcK1S1b (ORCPT ); Mon, 28 Nov 2016 13:27:31 -0500 Received: by mail-lf0-f65.google.com with SMTP id 98so10305966lfs.0; Mon, 28 Nov 2016 10:27:29 -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=MHRvXCxNDp+vDIrMtnqizbWAomOBeAfXtzMAumGyWfo=; b=u0lJlL9gG8A75Gao34SYPRK5ypAQ0A7YnF7sheFAO8d8qi29uD1+YJi6ChwzgDkzty /FxqOK6zFk+ZQp0craz/v5Ex9jkHV3QmdwDqx4j2jRgmFaUmOOwjHZ42FIp2XfyIFplc 5hCFo/RwSvJV+Mr5/Gj4n0yOzZ04UyCOPPSvNVLsT2QWd9rUMB+oNu6yxpuKfUZ3Y6PY 9fBLdQKTql2DUyyFpyQa0x2ah+hSWnt5PM6nabcYwxWYTX4qL67p0kTwR4LJU938tvZ1 v6O7v5gX745Zjn9WqTs4OHPwfPhjE+drZ5ypWJnFfO5Y2Ct7Mkwhz3KXn912SAnjTu1/ eBOg== 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=MHRvXCxNDp+vDIrMtnqizbWAomOBeAfXtzMAumGyWfo=; b=IuQTwjNAfnqj2SebTqfRj/4sc7lFAUMrxDmLPEGkjHlQFJfq0rc9DoU1q6xGiMAb8d itE9MQ/LnMH3DJXNet8wahaFtcsrOh4a+NmRpTN8WOEtnmqtRQ/jF6qXM9cku/EWujNp Y1i4jUCNTaGagdevFSU3MzgKFA2mVwlpNjfp3aJCRI6OygPb1bNY2Gm6eKy5d82dg+9u ofh3FMLJfDFhwjn8qJRdV4Xao95c7QF7Bri8lDzIy4DvipLoIwzaxWdS0nLJ9ytivsLq 40r7AB4JMb/As52vYInd/aqowAnO5hHPvE2de6MuJi6x2/HbXp8M58TBlaJkKJZzwXug CZ/w== X-Gm-Message-State: AKaTC01Ykb3O1B+cuH5IMGLAQoEwpr5X9fAmwRSf+dLMurVTP1aKOUC67HkK6vsJ7OyKYw== X-Received: by 10.46.77.92 with SMTP id a89mr10460115ljb.28.1480357648829; Mon, 28 Nov 2016 10:27:28 -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 18sm13021490ljj.7.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-0007Ke-Hg; 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 09/16] net: ethernet: gianfar: fix fixed-link phydev leaks Date: Mon, 28 Nov 2016 19:25:02 +0100 Message-Id: <1480357509-28074-10-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: be40364544bd ("gianfar: use the new fixed PHY helpers") Signed-off-by: Johan Hovold --- drivers/net/ethernet/freescale/gianfar.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c index 4b4f5bc0e279..9061c2f82b9c 100644 --- a/drivers/net/ethernet/freescale/gianfar.c +++ b/drivers/net/ethernet/freescale/gianfar.c @@ -1312,6 +1312,7 @@ static void gfar_init_addr_hash_table(struct gfar_private *priv) */ static int gfar_probe(struct platform_device *ofdev) { + struct device_node *np = ofdev->dev.of_node; struct net_device *dev = NULL; struct gfar_private *priv = NULL; int err = 0, i; @@ -1462,6 +1463,8 @@ static int gfar_probe(struct platform_device *ofdev) return 0; register_fail: + if (of_phy_is_fixed_link(np)) + of_phy_deregister_fixed_link(np); unmap_group_regs(priv); gfar_free_rx_queues(priv); gfar_free_tx_queues(priv); @@ -1474,11 +1477,16 @@ static int gfar_probe(struct platform_device *ofdev) static int gfar_remove(struct platform_device *ofdev) { struct gfar_private *priv = platform_get_drvdata(ofdev); + struct device_node *np = ofdev->dev.of_node; of_node_put(priv->phy_node); of_node_put(priv->tbi_node); unregister_netdev(priv->ndev); + + if (of_phy_is_fixed_link(np)) + of_phy_deregister_fixed_link(np); + unmap_group_regs(priv); gfar_free_rx_queues(priv); gfar_free_tx_queues(priv);