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: 9450033 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 0582A6074E for ; Mon, 28 Nov 2016 18:49:50 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED37827F90 for ; Mon, 28 Nov 2016 18:49:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E027E27FA1; Mon, 28 Nov 2016 18:49:49 +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 66E1327F90 for ; Mon, 28 Nov 2016 18:49:49 +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 1cBQzt-0003y8-1F; Mon, 28 Nov 2016 18:49:49 +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 1cBQzq-0003qz-C3 for linux-mediatek@lists.infradead.org; Mon, 28 Nov 2016 18:49:47 +0000 Received: by mail-lf0-x243.google.com with SMTP id 98so10362513lfs.0 for ; Mon, 28 Nov 2016 10:49:26 -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=H8UhxAiZ5lbSaelnbkTlP+hNH130wdME30qXud/NahO+Fbk3lfCBpZAjKCl9sjL2Vl 3Z0AbLVqPblu/D0+B80UTpq7nN1yWr4bDNdOVPyZY/ZxWffnATTnGBCS8yIyxYPO+WfE u3doBCw1LnHrKD8apU4PdOfGtFZwoZoAQ6x8tKO/LQ9ehoRhTAWAgBHJr972kZyv8ubX vJHFI0P3+q1f9kUMDvKG2ypx6MKuwsh9cvcET2N1nC6ynzo6FTxjLDUdBVkKrSHFv87y DNU7nW5wmhODwulJ6HroKVKhI37fwZfDLBrMZPV11H1tVS87YPfeDDNaNKJbayqghYlb ImEQ== X-Gm-Message-State: AKaTC00HMxdv/l3f81tYxZvjOFLPxN4Dt+CReN/uYMLyF+vyYgECRse3IYAVJ/yM5Gy61Q== 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" 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20161128_104946_650148_B69A26F4 X-CRM114-Status: UNSURE ( 9.27 ) 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 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); }