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: 9449891 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 DB5E16071C for ; Mon, 28 Nov 2016 18:28:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D00AF27F9C for ; Mon, 28 Nov 2016 18:28:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C4D2B28047; Mon, 28 Nov 2016 18:28:12 +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 7225727F9C for ; Mon, 28 Nov 2016 18:28:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754068AbcK1S1x (ORCPT ); Mon, 28 Nov 2016 13:27:53 -0500 Received: from mail-lf0-f67.google.com ([209.85.215.67]:34817 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751453AbcK1S13 (ORCPT ); Mon, 28 Nov 2016 13:27:29 -0500 Received: by mail-lf0-f67.google.com with SMTP id p100so10340562lfg.2; 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=kAuqGRU+18Hj7aWLcZ0c6HJiJ0Il+YHVDj5YZPq+XAgi/B6hDJe6rhPqofzxfcOVz4 lkd00Bs00Hm4V5cmSKk5kcnRj13eP/cNA1lhexqA2nRzo+xtWMm3ZPNAXvif0EbT7pol dLXTXxD8E4qurdM1KJJUKnE1K9ETBR9wYFWEUz/FZkzebZ6ntWE7I4x2Kc6VMdJkdRSj +lIJbImnYT/IQxFdNEiqDtEqieBnSI3Jp5b8BsUgZL3KGCg3T9bWBHE0l+XThav2Swhu 2xcQsE5Hu6EAh2Wq1pF1z4dJLxCkKZRACrfzqmx6yUA7ZabRb4/gnhsJs/byYVQvU5Vb YY1g== X-Gm-Message-State: AKaTC02X/7ctC5Im6+0VfAijsfNq0jSnSIEgamCZd2nrxNPePTnlO5sZjB0mcleQYS7f3w== 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" 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 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> 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 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);