net: phy: fix of_node and device leaks
Subsystems (4)
cover net: phy: fix of_node and device leaks
These patches fix a couple of of_node leaks in the fixed-link code and a device reference leak in a phy helper.
Johan
Johan Hovold (3):
of_mdio: fix node leak in of_phy_register_fixed_link error path
of_mdio: fix device reference leak in of_phy_find_device
net: phy: fixed_phy: fix of_node leak in fixed_phy_unregister
drivers/net/phy/fixed_phy.c | 2 +- drivers/of/of_mdio.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-)
Signature · 1 line
2.7.3
PATCH 1/3 of_mdio: fix node leak in of_phy_register_fixed_link error path
Make sure to drop the of_node reference also on failure to parse the speed property in of_phy_register_fixed_link().
--- drivers/of/of_mdio.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/of/of_mdio.c +4 -1
@@ -456,8 +456,11 @@ int of_phy_register_fixed_link(struct device_node *np) status.link =1 ; status.duplex =of_property_read_bool (fixed_link_node,"full-duplex" ); -if (of_property_read_u32 (fixed_link_node,"speed" , &status.speed)) +if (of_property_read_u32 (fixed_link_node,"speed" , + &status.speed)) { +of_node_put (fixed_link_node);return -EINVAL ; + } status.pause =of_property_read_bool (fixed_link_node,"pause" ); status.asym_pause =of_property_read_bool (fixed_link_node,"asym-pause" );
Signature · 1 line
2.7.3
PATCH 2/3 of_mdio: fix device reference leak in of_phy_find_device
In reply to Johan HovoldMake sure to drop the reference taken by bus_find_device() before returning NULL from of_phy_find_device() when the found device is not a PHY.
--- drivers/of/of_mdio.c | 1 + 1 file changed, 1 insertion(+)
drivers/of/of_mdio.c +1 -0
@@ -292,6 +292,7 @@ struct phy_device *of_phy_find_device(struct device_node *phy_np) mdiodev =to_mdio_device (d);if (mdiodev->flags &MDIO_DEVICE_FLAG_PHY )return to_phy_device (d); +put_device (d); }return NULL ;
Signature · 1 line
2.7.3
PATCH 3/3 net: phy: fixed_phy: fix of_node leak in fixed_phy_unregister
In reply to Johan HovoldMake sure to drop the of_node reference taken in fixed_phy_register() when deregistering a PHY.
fixed_phy_register()")
--- drivers/net/phy/fixed_phy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/phy/fixed_phy.c +1 -1
@@ -279,7 +279,7 @@ EXPORT_SYMBOL_GPL(fixed_phy_register);void fixed_phy_unregister (struct phy_device *phy) {phy_device_remove (phy); - +of_node_put (phy->mdio.dev.of_node);fixed_phy_del (phy->mdio.addr); }EXPORT_SYMBOL_GPL (fixed_phy_unregister);
Signature · 1 line
2.7.3
David Miller
maintainerFrom: Johan Hovold <[email protected]>
Date: Wed, 16 Nov 2016 15:20:35 +0100
Quoted 2 lines
These patches fix a couple of
of_nodeleaks in the fixed-link code and a device reference leak in a phy helper.
Series applied, thanks.