public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel•org>
To: "David S. Miller" <davem@davemloft•net>
Cc: Vince Bridgers <vbridger@opensource•altera.com>,
	Florian Fainelli <f.fainelli@gmail•com>,
	Fugang Duan <fugang.duan@nxp•com>,
	Pantelis Antoniou <pantelis.antoniou@gmail•com>,
	Vitaly Bordug <vbordug@ru•mvista.com>,
	Claudiu Manoil <claudiu.manoil@freescale•com>,
	Li Yang <leoli@freescale•com>,
	Thomas Petazzoni <thomas.petazzoni@free-electrons•com>,
	Felix Fietkau <nbd@openwrt•org>,
	John Crispin <blogic@openwrt•org>,
	Matthias Brugger <matthias.bgg@gmail•com>,
	Sergei Shtylyov <sergei.shtylyov@cogentembedded•com>,
	Lars Persson <lars.persson@axis•com>,
	Mugunthan V N <mugunthanvnm@ti•com>,
	Grygorii Strashko <grygorii.strashko@ti•com>,
	Rob Herring <robh+dt@kernel•org>,
	Frank Rowand <frowand.list@gmail•com>,
	Andrew Lunn <andrew@lunn•ch>,
	Vivien Didelot <vivien.didelot@savoirfairelinux•com>,
	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 <johan@kernel•org>
Subject: [PATCH net 01/16] net: dsa: slave: fix of-node leak and phy priority
Date: Mon, 28 Nov 2016 19:24:54 +0100	[thread overview]
Message-ID: <1480357509-28074-2-git-send-email-johan@kernel.org> (raw)
In-Reply-To: <1480357509-28074-1-git-send-email-johan@kernel.org>

Make sure to drop the reference taken by of_parse_phandle() before
returning from dsa_slave_phy_setup().

Note that this also modifies the PHY priority so that any fixed-link
node is only parsed when no phy-handle is given, which is in accordance
with the common scheme for this.

Fixes: 0d8bcdd383b8 ("net: dsa: allow for more complex PHY setups")
Signed-off-by: Johan Hovold <johan@kernel•org>
---
 net/dsa/slave.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 6b1282c006b1..2a5c20a13fe4 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1125,7 +1125,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
 	p->phy_interface = mode;
 
 	phy_dn = of_parse_phandle(port_dn, "phy-handle", 0);
-	if (of_phy_is_fixed_link(port_dn)) {
+	if (!phy_dn && of_phy_is_fixed_link(port_dn)) {
 		/* In the case of a fixed PHY, the DT node associated
 		 * to the fixed PHY is the Port DT node
 		 */
@@ -1135,7 +1135,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
 			return ret;
 		}
 		phy_is_fixed = true;
-		phy_dn = port_dn;
+		phy_dn = of_node_get(port_dn);
 	}
 
 	if (ds->ops->get_phy_flags)
@@ -1154,6 +1154,7 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
 			ret = dsa_slave_phy_connect(p, slave_dev, phy_id);
 			if (ret) {
 				netdev_err(slave_dev, "failed to connect to phy%d: %d\n", phy_id, ret);
+				of_node_put(phy_dn);
 				return ret;
 			}
 		} else {
@@ -1162,6 +1163,8 @@ static int dsa_slave_phy_setup(struct dsa_slave_priv *p,
 						phy_flags,
 						p->phy_interface);
 		}
+
+		of_node_put(phy_dn);
 	}
 
 	if (p->phy && phy_is_fixed)
-- 
2.7.3

  reply	other threads:[~2016-11-28 18:27 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-28 18:24 [PATCH net 00/16] net: fix fixed-link phydev leaks Johan Hovold
2016-11-28 18:24 ` Johan Hovold [this message]
2016-11-28 18:24 ` [PATCH net 02/16] of_mdio: add helper to deregister fixed-link PHYs Johan Hovold
2016-11-28 18:24 ` [PATCH net 03/16] net: ethernet: altera: fix fixed-link phydev leaks Johan Hovold
2016-11-28 18:24 ` [PATCH net 04/16] net: ethernet: aurora: nb8800: " Johan Hovold
2016-11-28 18:24 ` [PATCH net 05/16] net: ethernet: bcmsysport: " Johan Hovold
2016-11-28 18:24 ` [PATCH net 06/16] net: ethernet: bcmgenet: " Johan Hovold
2016-11-28 18:25 ` [PATCH net 07/16] net: ethernet: fec: " Johan Hovold
2016-11-28 18:25 ` [PATCH net 08/16] net: ethernet: fs_enet: " Johan Hovold
2016-11-28 18:25 ` [PATCH net 09/16] net: ethernet: gianfar: " Johan Hovold
2016-11-28 18:25 ` [PATCH net 10/16] net: ethernet: ucc_geth: " Johan Hovold
2016-11-28 18:25 ` [PATCH net 11/16] net: ethernet: marvell: mvneta: " Johan Hovold
2016-11-28 20:10   ` Thomas Petazzoni
2020-05-06 18:57   ` Naresh Kamboju
2020-05-07  6:44     ` Johan Hovold
2020-05-07  6:47       ` Greg Kroah-Hartman
2020-05-07 11:13         ` Greg Kroah-Hartman
2020-05-07 22:05           ` Naresh Kamboju
2020-05-08  6:21             ` Johan Hovold
2020-05-08 12:02               ` Greg Kroah-Hartman
2016-11-28 18:25 ` [PATCH net 12/16] net: ethernet: mediatek: " Johan Hovold
2016-11-28 18:25 ` [PATCH net 13/16] net: ethernet: renesas: ravb: " Johan Hovold
2016-11-28 18:25 ` [PATCH net 14/16] net: ethernet: dwc_eth_qos: " Johan Hovold
2016-11-28 18:25 ` [PATCH net 15/16] net: ethernet: ti: davinci_emac: fix fixed-link phydev and of-node leaks Johan Hovold
2016-11-28 18:25 ` [PATCH net 16/16] net: dsa: slave: fix fixed-link phydev leaks Johan Hovold
2016-11-30  4:17 ` [PATCH net 00/16] net: " David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1480357509-28074-2-git-send-email-johan@kernel.org \
    --to=johan@kernel$(echo .)org \
    --cc=andrew@lunn$(echo .)ch \
    --cc=blogic@openwrt$(echo .)org \
    --cc=claudiu.manoil@freescale$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=devicetree@vger$(echo .)kernel.org \
    --cc=f.fainelli@gmail$(echo .)com \
    --cc=frowand.list@gmail$(echo .)com \
    --cc=fugang.duan@nxp$(echo .)com \
    --cc=grygorii.strashko@ti$(echo .)com \
    --cc=lars.persson@axis$(echo .)com \
    --cc=leoli@freescale$(echo .)com \
    --cc=linux-kernel@vger$(echo .)kernel.org \
    --cc=linux-mediatek@lists$(echo .)infradead.org \
    --cc=linux-omap@vger$(echo .)kernel.org \
    --cc=linux-renesas-soc@vger$(echo .)kernel.org \
    --cc=linuxppc-dev@lists$(echo .)ozlabs.org \
    --cc=matthias.bgg@gmail$(echo .)com \
    --cc=mugunthanvnm@ti$(echo .)com \
    --cc=nbd@openwrt$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=nios2-dev@lists$(echo .)rocketboards.org \
    --cc=pantelis.antoniou@gmail$(echo .)com \
    --cc=robh+dt@kernel$(echo .)org \
    --cc=sergei.shtylyov@cogentembedded$(echo .)com \
    --cc=thomas.petazzoni@free-electrons$(echo .)com \
    --cc=vbordug@ru$(echo .)mvista.com \
    --cc=vbridger@opensource$(echo .)altera.com \
    --cc=vivien.didelot@savoirfairelinux$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox