From patchwork Mon Nov 28 18:25:05 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9450027 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 119306074E for ; Mon, 28 Nov 2016 18:49:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 054FA27FA1 for ; Mon, 28 Nov 2016 18:49:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EB59E27FA7; Mon, 28 Nov 2016 18:49:30 +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=ham 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 97DC627F90 for ; Mon, 28 Nov 2016 18:49:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753809AbcK1St3 (ORCPT ); Mon, 28 Nov 2016 13:49:29 -0500 Received: from mail-lf0-f66.google.com ([209.85.215.66]:32971 "EHLO mail-lf0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751168AbcK1St0 (ORCPT ); Mon, 28 Nov 2016 13:49:26 -0500 Received: by mail-lf0-f66.google.com with SMTP id 98so10362514lfs.0; Mon, 28 Nov 2016 10:49:25 -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=Y7whHaEPV4PsFfKm/cH8de7J7V7nk3AmRV+7RWhBOx0=; b=Kvs/iG+tgjDC9I17x1EQ6eNaNfVCY9q2KCPsTyEzalbrx6sf+rm3DByc5m5gB6ylAS boazVo4YKVdUUGWGDI2pPBriH5L60ehfr/vajDhMGihwFm5jKD8Zy7VJAg2Cm7tArYgM otkHHCYL7DrsT//eZ5ccF/GaZlftCS/Uudi6zO4u9tgQ9no9QILSiAOrTwhXvfQ/uODk 0BASBuzA4Y/zuinyKd5/L3QP4/lzB5sUxTo5rmBAx7TBadDLIoYivD/auRSHrBy57hNL KMV2A5JgHWzl8lWrXeEsO2qSLx5XjHlasl8YKn6zhprtoyUpy7YUJqwj7F5cTUqYPcDf JLNg== 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=Y7whHaEPV4PsFfKm/cH8de7J7V7nk3AmRV+7RWhBOx0=; b=DboEfoGoVvzxVm9sQmRW33K74fe7f25IXVqMbLsH8QbyPDeuCWz1ed+xE6bT+KOoeN Whjq5hwR+eCdkaqOrB/5sgiKEgHk00nPJcAQDbvQ3ShLVYXO7Nrw892HpTJGxwZMp1OQ +QdbVkI/kULZBQFFIAlYDghxt9fXVx3mmZwo2NI/7wxqHnvAhWIc3zg5ppymYBrGfWVC EiQNSFJxdJ+t0FmP4GGhc6a3IogZsbebJ9g7ApO+7ePMsQz2W/2dtdTUMLSZz9rYiUGV 58eK5qqsdVNJC1sk9C25uE5O5CPFyK1cclv/81DMaC2hX0kWSH9gszbn2g3Kl6RrSILP xxew== X-Gm-Message-State: AKaTC005+N7YPV83TnY4mRqht9UOrsSxmjG6D4QCiM7qnDJVd94JDw5URkhjrz/SCFIV1Q== X-Received: by 10.25.198.16 with SMTP id w16mr8561676lff.44.1480358964473; Mon, 28 Nov 2016 10:49:24 -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 f124sm12981613lff.34.2016.11.28.10.49.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 10:49:23 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.87) (envelope-from ) id 1cBQeA-0007Kv-QG; 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 12/16] net: ethernet: mediatek: fix fixed-link phydev leaks Date: Mon, 28 Nov 2016 19:25:05 +0100 Message-Id: <1480357509-28074-13-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 initialisation errors and on uninit. Fixes: 0c72c50f6f93 ("net-next: mediatek: add fixed-phy support") Signed-off-by: Johan Hovold --- drivers/net/ethernet/mediatek/mtk_eth_soc.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/ethernet/mediatek/mtk_eth_soc.c b/drivers/net/ethernet/mediatek/mtk_eth_soc.c index 4a62ffd7729d..86a89cbd3ec9 100644 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c @@ -318,6 +318,8 @@ static int mtk_phy_connect(struct net_device *dev) return 0; err_phy: + if (of_phy_is_fixed_link(mac->of_node)) + of_phy_deregister_fixed_link(mac->of_node); of_node_put(np); dev_err(eth->dev, "%s: invalid phy\n", __func__); return -EINVAL; @@ -1923,6 +1925,8 @@ static void mtk_uninit(struct net_device *dev) struct mtk_eth *eth = mac->hw; phy_disconnect(dev->phydev); + if (of_phy_is_fixed_link(mac->of_node)) + of_phy_deregister_fixed_link(mac->of_node); mtk_irq_disable(eth, MTK_QDMA_INT_MASK, ~0); mtk_irq_disable(eth, MTK_PDMA_INT_MASK, ~0); }