From patchwork Mon Nov 28 18:24:56 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9449899 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 8F12E6071C for ; Mon, 28 Nov 2016 18:28:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8551827F9C for ; Mon, 28 Nov 2016 18:28:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 79BD227FB6; Mon, 28 Nov 2016 18:28:16 +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 3BCA527F9C for ; Mon, 28 Nov 2016 18:28:16 +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 1cBQf1-0001a9-KU; Mon, 28 Nov 2016 18:28:15 +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 1cBQea-00013Y-9U for linux-mediatek@lists.infradead.org; Mon, 28 Nov 2016 18:27:53 +0000 Received: by mail-lf0-x243.google.com with SMTP id o141so10368966lff.1 for ; Mon, 28 Nov 2016 10:27:28 -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=QPD/v3veThyazYbQpx077xdz4zadSm+mKG5AbQ2i8DQ=; b=s+GuWPUwZail0ZAKywloqPT3hoTnPYh/Cyy0Y7sfuB8Yqc1vQQaBI3Ji7B0ErXd3nu Xj1eXF1gSa0z0/6Q4Om8G/3nohtDFmR3oAz/rNoBYRk7p9yuJJHhWsitWUE5XC0LiOrF VA5Cs7JIGzbWmexJVHGV1tQJ7LLMDrDSNgu6HMrjte+gtCIzJYaEzj/YHXbQLypRMCxX bGW5lTr6CZ5j3lTuDTSjbiMl4td3bV3s0qyV5CbYh/TU01lmkxP7ocpptQ20gbLBTHKB LpCBNe4XLoMsprQiAldBPaFI7DKjIzoqO044g+c1M5yAzayYZw6ANw7GfcYLod9wF1I6 hZ7A== 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=QPD/v3veThyazYbQpx077xdz4zadSm+mKG5AbQ2i8DQ=; b=TEFowS/C5NhFZUKo0DAuWKLFkfkwsQJ+PQPcUh7ybe2BJT3RKyFmG6bugnW25rUDUt bparJaWm2fckoowpt1C7TWJLpsaMaxI74z6GH+G9iDAuA8bV0mhVtSdMeiireAEYE+yu e+FYgnHZb5eCR8IuWVOV3fxKANF9VnlUZVZVCyLlRKf8EfbpoeYnEV9CPDJrjHmosV3w 6qGMHxbodfGnAN06S4Z2VepZ7OK0CVNyDI8lNRuiJVjW9zswwbKJbwzl5W3rtaRIlZT3 ip0Fi/IdxrbtaXqYy5gLom677sRKPKNIw8Sq7JgBWowNZTdlZItDJIss20iRYEhKFPkh 8l9g== X-Gm-Message-State: AKaTC01Sbyq+XA5PWfabRYTr97kCbwlWQNueBSXLUQxkGxysT16y65ZbPsYKLG9KsfGI7Q== X-Received: by 10.46.78.10 with SMTP id c10mr11309784ljb.77.1480357647245; Mon, 28 Nov 2016 10:27:27 -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 w67sm12795365lff.16.2016.11.28.10.27.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 10:27:25 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.87) (envelope-from ) id 1cBQeA-0007KA-2r; Mon, 28 Nov 2016 19:27:22 +0100 From: Johan Hovold To: "David S. Miller" Subject: [PATCH net 03/16] net: ethernet: altera: fix fixed-link phydev leaks Date: Mon, 28 Nov 2016 19:24:56 +0100 Message-Id: <1480357509-28074-4-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_755696_311C69D4 X-CRM114-Status: GOOD ( 11.87 ) 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: 7cdbc6f74f8e ("altera tse: add support for fixed-links.") Signed-off-by: Johan Hovold --- drivers/net/ethernet/altera/altera_tse_main.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c index bda31f308cc2..6532829b70d2 100644 --- a/drivers/net/ethernet/altera/altera_tse_main.c +++ b/drivers/net/ethernet/altera/altera_tse_main.c @@ -819,6 +819,8 @@ static int init_phy(struct net_device *dev) if (!phydev) { netdev_err(dev, "Could not find the PHY\n"); + if (fixed_link) + of_phy_deregister_fixed_link(priv->device->of_node); return -ENODEV; } @@ -1545,10 +1547,15 @@ static int altera_tse_probe(struct platform_device *pdev) static int altera_tse_remove(struct platform_device *pdev) { struct net_device *ndev = platform_get_drvdata(pdev); + struct altera_tse_private *priv = netdev_priv(ndev); - if (ndev->phydev) + if (ndev->phydev) { phy_disconnect(ndev->phydev); + if (of_phy_is_fixed_link(priv->device->of_node)) + of_phy_deregister_fixed_link(priv->device->of_node); + } + platform_set_drvdata(pdev, NULL); altera_tse_mdio_destroy(ndev); unregister_netdev(ndev);