Skip to content

Commit c8cbcb0

Browse files
jhovolddavem330
authored andcommitted
net: dsa: lantiq_gswip: fix OF child-node lookups
Use the new of_get_compatible_child() helper to look up child nodes to avoid ever matching non-child nodes elsewhere in the tree. Also fix up the related struct device_node leaks. Fixes: 14fceff ("net: dsa: Add Lantiq / Intel DSA driver for vrx200") Cc: stable <[email protected]> # 4.20 Cc: Hauke Mehrtens <[email protected]> Signed-off-by: Johan Hovold <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Acked-by: Hauke Mehrtens <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent aed13f2 commit c8cbcb0

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

drivers/net/dsa/lantiq_gswip.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,24 +1069,23 @@ static int gswip_probe(struct platform_device *pdev)
10691069
version = gswip_switch_r(priv, GSWIP_VERSION);
10701070

10711071
/* bring up the mdio bus */
1072-
gphy_fw_np = of_find_compatible_node(pdev->dev.of_node, NULL,
1073-
"lantiq,gphy-fw");
1072+
gphy_fw_np = of_get_compatible_child(dev->of_node, "lantiq,gphy-fw");
10741073
if (gphy_fw_np) {
10751074
err = gswip_gphy_fw_list(priv, gphy_fw_np, version);
1075+
of_node_put(gphy_fw_np);
10761076
if (err) {
10771077
dev_err(dev, "gphy fw probe failed\n");
10781078
return err;
10791079
}
10801080
}
10811081

10821082
/* bring up the mdio bus */
1083-
mdio_np = of_find_compatible_node(pdev->dev.of_node, NULL,
1084-
"lantiq,xrx200-mdio");
1083+
mdio_np = of_get_compatible_child(dev->of_node, "lantiq,xrx200-mdio");
10851084
if (mdio_np) {
10861085
err = gswip_mdio(priv, mdio_np);
10871086
if (err) {
10881087
dev_err(dev, "mdio probe failed\n");
1089-
goto gphy_fw;
1088+
goto put_mdio_node;
10901089
}
10911090
}
10921091

@@ -1115,7 +1114,8 @@ static int gswip_probe(struct platform_device *pdev)
11151114
mdio_bus:
11161115
if (mdio_np)
11171116
mdiobus_unregister(priv->ds->slave_mii_bus);
1118-
gphy_fw:
1117+
put_mdio_node:
1118+
of_node_put(mdio_np);
11191119
for (i = 0; i < priv->num_gphy_fw; i++)
11201120
gswip_gphy_fw_remove(priv, &priv->gphy_fw[i]);
11211121
return err;
@@ -1134,8 +1134,10 @@ static int gswip_remove(struct platform_device *pdev)
11341134

11351135
dsa_unregister_switch(priv->ds);
11361136

1137-
if (priv->ds->slave_mii_bus)
1137+
if (priv->ds->slave_mii_bus) {
11381138
mdiobus_unregister(priv->ds->slave_mii_bus);
1139+
of_node_put(priv->ds->slave_mii_bus->dev.of_node);
1140+
}
11391141

11401142
for (i = 0; i < priv->num_gphy_fw; i++)
11411143
gswip_gphy_fw_remove(priv, &priv->gphy_fw[i]);

0 commit comments

Comments
 (0)