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: 700099 X-Patchwork-Delegate: davem@davemloft.net Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 3tSFdy6tdZz9t26 for ; Tue, 29 Nov 2016 05:32:22 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="lUKNhT1y"; dkim-atps=neutral Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754655AbcK1S2f (ORCPT ); Mon, 28 Nov 2016 13:28:35 -0500 Received: from mail-lf0-f65.google.com ([209.85.215.65]:33766 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753154AbcK1S1f (ORCPT ); Mon, 28 Nov 2016 13:27:35 -0500 Received: by mail-lf0-f65.google.com with SMTP id 98so10306188lfs.0; 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=k7KGBvOYYyqlpV8bix16WSGPvYuTzOoU2J2E4OvLSd0goqFWZIL9eY2GPTrY4o+Zw9 7q3ITz9bNOf/MKnUAQCISB4BW6cpcfwhnU8AOkawKLaYWuQVS6bm/3kiD0XXkwAwmanz pesOaO3C2XhVlA+CP6/M1z99QJsWGcy92ROM5y8yHSITJjcOTVO0vWFgG6XTcXLVGtd6 NZUydtZj/Ogt1SQ7zhnlcOzPrbKEHkXyBeQ6lCv5oSlkZxVNTKtXccaGAYzK8kvjGwAu 8ptfzqw3abJ52/BLM32JScqMWhJDn3RqkKFGi8wxdDMu9j+ipPonX3d314JtmYgndsF5 lolg== X-Gm-Message-State: AKaTC01wM6qOCN6TBFnMKDnvWZbVNfBAHs4VbFrmkHEnp//pigalIW9WZNRmCGZwkqFy7Q== 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" 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 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> Sender: netdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org 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); }