From patchwork Mon Nov 28 18:25:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9449911 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 6304B6071C for ; Mon, 28 Nov 2016 18:28:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5928627F9C for ; Mon, 28 Nov 2016 18:28:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4DD7A27FB6; Mon, 28 Nov 2016 18:28:23 +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 E615027F9C for ; Mon, 28 Nov 2016 18:28:22 +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 1cBQf7-0001fC-Tn; Mon, 28 Nov 2016 18:28:21 +0000 Received: from mail-lf0-x244.google.com ([2a00:1450:4010:c07::244]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1cBQec-00014r-O5 for linux-mediatek@lists.infradead.org; Mon, 28 Nov 2016 18:27:57 +0000 Received: by mail-lf0-x244.google.com with SMTP id o20so10330417lfg.3 for ; Mon, 28 Nov 2016 10:27:32 -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=JxhG/SKj6hyFWZ6z3goANqOD3v4aGyUbxaqHO1Dwilc=; b=Yb4lkkbxcuXpJKxfGgv/xvCBYLR78uVEvjIIBKNgMb1vfOYRfUbJGcDdUrmOopofbK +xl7U17Nc2IUAoidpFDgn/4UOhV+rziKj1bdcgsqumHkpeABuh6biVvtGLouYskJPO9p iWm1pnBMOIIuQc1nn/kyNLAw55kLJnGgIXC6XHdNrWqe7yUOhT3C77pxKjAMn1JoAUir mVPM3Ek7IRpafpd+s7O32fAKe6F1MkmVcZUC8F/jfWT6Idfu4apg+/9GaGxQDl+siiSb Hlg8TbigQPW5XzXBIL1XGvXUlUT2Q+IRU+SfZTqiS5Q5fnvHifXujJllhdSj/YmdOZSG poBg== 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=JxhG/SKj6hyFWZ6z3goANqOD3v4aGyUbxaqHO1Dwilc=; b=lbRrEFbzz5Iz1OGjKcyPmH+wnyxmgzD+Ioam+RdRsCnxPK3dpwIek3qGRguVJU9h8j OZppJsPhlCEj542FADmT4uJNz/soS1isoVFKySMyhi4k1UYLBCheQ60YGcDNh0H1eoED LVtCyQyzk68YX9Xv5eJfTS66Pd3wLFhLLHpydhYs5NM/VDxar/aGbolRpv8MVslhuRI/ 4DzpK69aFQnqowxiO/U01sq6LxFf3lshczJJhKbMVt/AHbOfXLnWzNafcx4H8Td8nVSg FLJQFpc7j1B0bEOMMXmY3iKcuRYfIjLJTTkykXdTVeBj2A2AAcT4PpJsGWI2go/KUJvj Pi8A== X-Gm-Message-State: AKaTC01ybyoLKpxaApanC7YscMSgpWWRKaZifZ4Y5wJnFOLKouolWwFHCnWvUr5hRgpyfA== X-Received: by 10.46.5.140 with SMTP id 134mr10713308ljf.66.1480357650800; Mon, 28 Nov 2016 10:27:30 -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 e78sm13025870lfg.23.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-0007KZ-Eo; Mon, 28 Nov 2016 19:27:22 +0100 From: Johan Hovold To: "David S. Miller" Subject: [PATCH net 08/16] net: ethernet: fs_enet: fix fixed-link phydev leaks Date: Mon, 28 Nov 2016 19:25:01 +0100 Message-Id: <1480357509-28074-9-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_102751_352072_65ACCF66 X-CRM114-Status: GOOD ( 10.57 ) 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: bb74d9a4a87b ("fs_enet: use the new fixed PHY helpers") Signed-off-by: Johan Hovold --- drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c index dc120c148d97..4b86260584a0 100644 --- a/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c +++ b/drivers/net/ethernet/freescale/fs_enet/fs_enet-main.c @@ -980,7 +980,7 @@ static int fs_enet_probe(struct platform_device *ofdev) err = clk_prepare_enable(clk); if (err) { ret = err; - goto out_free_fpi; + goto out_deregister_fixed_link; } fpi->clk_per = clk; } @@ -1061,6 +1061,9 @@ static int fs_enet_probe(struct platform_device *ofdev) of_node_put(fpi->phy_node); if (fpi->clk_per) clk_disable_unprepare(fpi->clk_per); +out_deregister_fixed_link: + if (of_phy_is_fixed_link(ofdev->dev.of_node)) + of_phy_deregister_fixed_link(ofdev->dev.of_node); out_free_fpi: kfree(fpi); return ret; @@ -1079,6 +1082,8 @@ static int fs_enet_remove(struct platform_device *ofdev) of_node_put(fep->fpi->phy_node); if (fep->fpi->clk_per) clk_disable_unprepare(fep->fpi->clk_per); + if (of_phy_is_fixed_link(ofdev->dev.of_node)) + of_phy_deregister_fixed_link(ofdev->dev.of_node); free_netdev(ndev); return 0; }