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: 9449895 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 ADE8B60756 for ; Mon, 28 Nov 2016 18:28:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A19B327F9C for ; Mon, 28 Nov 2016 18:28:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 95D0027FB6; Mon, 28 Nov 2016 18:28:13 +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 51BAB27F9C for ; Mon, 28 Nov 2016 18:28:13 +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 1cBQey-0001YI-93; Mon, 28 Nov 2016 18:28:12 +0000 Received: from mail-lf0-x241.google.com ([2a00:1450:4010:c07::241]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBQea-00014K-2f for linux-mediatek@lists.infradead.org; Mon, 28 Nov 2016 18:27:50 +0000 Received: by mail-lf0-x241.google.com with SMTP id p100so10340672lfg.2 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=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=S9X7X0q2+lzvFWXlRBrfFTw6aXf/lYWpcWhNQbpA2Uc5ZUAbOgxGpqckK0Z1yHOAbX pZDxo7eAZXWtGsvHaNNPftSARYyJ97FMYRFglqBrUnAiNkqk9ynrgiqt6rll3SsLEraw LXVTnKImuuI2Xk4p5L6YaXpS2ZPahO6DdsHQID3sDTay7Y+lQcRlXxtZbIxfBKhK+DTe pW9XVRkoh4YTM3VHKnB8KVdvNylY+R3Q3OJOp7K0GqLecB5xYdMpgPVrV4R+ITQ2594Q IMAQjApGwNAqE+cbJOCT89xFwZSKpzZj5nMtyvvh1WllgJcP8loEhzIkGnXDy/Ay0cP/ tnTg== X-Gm-Message-State: AKaTC02Khv+4AuqFar5XJG/apT94TQT0Ne5T6k4kWEinWfIENqLG9CZ+nocZPBoJlVwtig== 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" 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161128_102748_459017_3B78E5D4 X-CRM114-Status: GOOD ( 10.45 ) 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: 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);