lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Thu,  7 Aug 2014 21:41:46 +0200
From:	Uwe Kleine-König 
	<u.kleine-koenig@...gutronix.de>
To:	netdev@...r.kernel.org
Cc:	Claudiu Manoil <claudiu.manoil@...escale.com>,
	kernel@...gutronix.de, Florian Fainelli <f.fainelli@...il.com>,
	Fabio Estevam <fabio.estevam@...escale.com>,
	Thomas Petazzoni <thomas.petazzoni@...e-electrons.com>
Subject: [PATCH v2] net: gianfar: fix reference counting for phy_node

The line before the changed if condition is:

	priv->phy_node = of_parse_phandle(np, "phy-handle", 0);

. If this call succeeds priv->phy_node must not be overwritten in the if
block; otherwise the reference to the node returned by of_parse_phandle
is lost. So add a check that the if block isn't executed in this case.

Furthermore in the fixed phy case no reference is aquired for phy_node
resulting in an of_node_put without holding a reference. To fix that,
get a reference on the MAC dt node.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
---
Changes since (implicit) v1:

 - really do both fixes mentioned in the commit log

 drivers/net/ethernet/freescale/gianfar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/freescale/gianfar.c b/drivers/net/ethernet/freescale/gianfar.c
index 6b0c4775cd0d..fb29d049f4e1 100644
--- a/drivers/net/ethernet/freescale/gianfar.c
+++ b/drivers/net/ethernet/freescale/gianfar.c
@@ -892,12 +892,12 @@ static int gfar_of_init(struct platform_device *ofdev, struct net_device **pdev)
 	/* In the case of a fixed PHY, the DT node associated
 	 * to the PHY is the Ethernet MAC DT node.
 	 */
-	if (of_phy_is_fixed_link(np)) {
+	if (!priv->phy_node && of_phy_is_fixed_link(np)) {
 		err = of_phy_register_fixed_link(np);
 		if (err)
 			goto err_grp_init;
 
-		priv->phy_node = np;
+		priv->phy_node = of_node_get(np);
 	}
 
 	/* Find the TBI PHY.  If it's not there, we don't support SGMII */
-- 
2.0.1

--
To unsubscribe from this list: send the line "unsubscribe netdev" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ