From patchwork Mon Nov 28 18:25:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 9449909 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 4A9376071C for ; Mon, 28 Nov 2016 18:28:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 40BE527F9C for ; Mon, 28 Nov 2016 18:28:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3527527FBB; Mon, 28 Nov 2016 18:28:21 +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 C0A8927FB3 for ; Mon, 28 Nov 2016 18:28:20 +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 1cBQf6-0001dv-7I; Mon, 28 Nov 2016 18:28:20 +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-00015O-Nv for linux-mediatek@lists.infradead.org; Mon, 28 Nov 2016 18:27:57 +0000 Received: by mail-lf0-x244.google.com with SMTP id o20so10330507lfg.3 for ; Mon, 28 Nov 2016 10:27:33 -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=jgBzppJ2b1iVgujwim8DYluu7EvGPja0B4IGDjLjpVM=; b=lUKNhT1yNqERMPiH3P+oecCU5dsIhsciTcH9Dxq2DwFFz8S92VHPwVSykULA+G+4al zOpJI+jr/CfzvGkRN3uA2KuIuaf1Ce4NyDB1ZsC/gL6chkH/X/ymh71zaue8nx+ui0nq KMer0IitsEIFpXRhQcJ4HxC0CDDQQT8R5ytnSLsBi8sgKPZXCaXrZu2n/QATmU87ILHJ pGk528UrVii6TPeIjvpaeujGztIsmSPOzf3hfdk6Tfgx8GnDvHhtJBrDCasgm7Y2K4Ah Ns8TV6t5ki+LSORgWLYdvLce1i9L8SGwWEl/OFBatJJx385feewIWZJ/mQvyRw6Mqrpu jJ2g== 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=jgBzppJ2b1iVgujwim8DYluu7EvGPja0B4IGDjLjpVM=; b=T+shDnleZs2wNDRenkbqUkumacfL8aoTOepIj5DlimGys2VRCTZ/xbHxePtrp/+/pv sUtPkFOsd4PZ2Lh5Pn3eNP/d8pJUlGgkcghf4SIzr040khHWeXsmfztGs0mk3ypGw+/Z iENISaMRZMiWOezcl5K1B3xq0N9+WfD+QACt76xVn6AG5NoTWCtuFCcgWeylTjoDfqzZ YfQN3inePNW8artk1gCmhfVeV3lnWDd02mPJpILqpJpV/a/neSjZjmHBbWmvHe7+1IGg +fhuyMK6en77aVef7Rj7oBkewSqBIiYzeWD/UoDbHHgjcGk/Xzg38LXL0JfZibwgLNR6 qbyw== X-Gm-Message-State: AKaTC03hWLNlEcGVP6GndUJc8vkLB6XwMovgL8GWeEDCFpoZV524+ks/SD0Mo06M2IZiog== X-Received: by 10.25.44.66 with SMTP id s63mr8707158lfs.159.1480357652345; Mon, 28 Nov 2016 10:27:32 -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 a9sm12831857ljb.9.2016.11.28.10.27.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Nov 2016 10:27:30 -0800 (PST) Received: from johan by xi.terra with local (Exim 4.87) (envelope-from ) id 1cBQeB-0007LF-4v; Mon, 28 Nov 2016 19:27:23 +0100 From: Johan Hovold To: "David S. Miller" Subject: [PATCH net 16/16] net: dsa: slave: fix fixed-link phydev leaks Date: Mon, 28 Nov 2016 19:25:09 +0100 Message-Id: <1480357509-28074-17-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_289464_D8EAD5A6 X-CRM114-Status: GOOD ( 12.16 ) 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 slave-setup errors and on slave destroy. Fixes: 0d8bcdd383b8 ("net: dsa: allow for more complex PHY setups") Signed-off-by: Johan Hovold --- net/dsa/slave.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/net/dsa/slave.c b/net/dsa/slave.c index 2a5c20a13fe4..30e2e21d7619 100644 --- a/net/dsa/slave.c +++ b/net/dsa/slave.c @@ -1177,6 +1177,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p, ret = dsa_slave_phy_connect(p, slave_dev, p->port); if (ret) { netdev_err(slave_dev, "failed to connect to port %d: %d\n", p->port, ret); + if (phy_is_fixed) + of_phy_deregister_fixed_link(port_dn); return ret; } } @@ -1292,10 +1294,18 @@ int dsa_slave_create(struct dsa_switch *ds, struct device *parent, void dsa_slave_destroy(struct net_device *slave_dev) { struct dsa_slave_priv *p = netdev_priv(slave_dev); + struct dsa_switch *ds = p->parent; + struct device_node *port_dn; + + port_dn = ds->ports[p->port].dn; netif_carrier_off(slave_dev); - if (p->phy) + if (p->phy) { phy_disconnect(p->phy); + + if (of_phy_is_fixed_link(port_dn)) + of_phy_deregister_fixed_link(port_dn); + } unregister_netdev(slave_dev); free_netdev(slave_dev); }