* [PATCH net 0/3] net: phy: fix of_node and device leaks
@ 2016-11-16 14:20 Johan Hovold
2016-11-16 14:20 ` [PATCH net 1/3] of_mdio: fix node leak in of_phy_register_fixed_link error path Johan Hovold
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Johan Hovold @ 2016-11-16 14:20 UTC (permalink / raw)
To: Florian Fainelli
Cc: Rob Herring, Frank Rowand, netdev, linux-kernel, Johan Hovold
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(-)
--
2.7.3
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH net 1/3] of_mdio: fix node leak in of_phy_register_fixed_link error path
2016-11-16 14:20 [PATCH net 0/3] net: phy: fix of_node and device leaks Johan Hovold
@ 2016-11-16 14:20 ` Johan Hovold
2016-11-16 14:20 ` [PATCH net 2/3] of_mdio: fix device reference leak in of_phy_find_device Johan Hovold
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2016-11-16 14:20 UTC (permalink / raw)
To: Florian Fainelli
Cc: Rob Herring, Frank Rowand, netdev, linux-kernel, Johan Hovold
Make sure to drop the of_node reference also on failure to parse the
speed property in of_phy_register_fixed_link().
Fixes: 3be2a49e5c08 ("of: provide a binding for fixed link PHYs")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/of/of_mdio.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index b470f7e3521d..8f4648383fb2 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -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");
--
2.7.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 2/3] of_mdio: fix device reference leak in of_phy_find_device
2016-11-16 14:20 [PATCH net 0/3] net: phy: fix of_node and device leaks Johan Hovold
2016-11-16 14:20 ` [PATCH net 1/3] of_mdio: fix node leak in of_phy_register_fixed_link error path Johan Hovold
@ 2016-11-16 14:20 ` Johan Hovold
2016-11-16 14:20 ` [PATCH net 3/3] net: phy: fixed_phy: fix of_node leak in fixed_phy_unregister Johan Hovold
2016-11-17 17:05 ` [PATCH net 0/3] net: phy: fix of_node and device leaks David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2016-11-16 14:20 UTC (permalink / raw)
To: Florian Fainelli
Cc: Rob Herring, Frank Rowand, netdev, linux-kernel, Johan Hovold
Make 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.
Fixes: 6ed742363b9c ("of: of_mdio: Ensure mdio device is a PHY")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/of/of_mdio.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/of/of_mdio.c b/drivers/of/of_mdio.c
index 8f4648383fb2..5a3145a02547 100644
--- a/drivers/of/of_mdio.c
+++ b/drivers/of/of_mdio.c
@@ -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;
--
2.7.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH net 3/3] net: phy: fixed_phy: fix of_node leak in fixed_phy_unregister
2016-11-16 14:20 [PATCH net 0/3] net: phy: fix of_node and device leaks Johan Hovold
2016-11-16 14:20 ` [PATCH net 1/3] of_mdio: fix node leak in of_phy_register_fixed_link error path Johan Hovold
2016-11-16 14:20 ` [PATCH net 2/3] of_mdio: fix device reference leak in of_phy_find_device Johan Hovold
@ 2016-11-16 14:20 ` Johan Hovold
2016-11-17 17:05 ` [PATCH net 0/3] net: phy: fix of_node and device leaks David Miller
3 siblings, 0 replies; 5+ messages in thread
From: Johan Hovold @ 2016-11-16 14:20 UTC (permalink / raw)
To: Florian Fainelli
Cc: Rob Herring, Frank Rowand, netdev, linux-kernel, Johan Hovold
Make sure to drop the of_node reference taken in fixed_phy_register()
when deregistering a PHY.
Fixes: a75951217472 ("net: phy: extend fixed driver with
fixed_phy_register()")
Signed-off-by: Johan Hovold <johan@kernel.org>
---
drivers/net/phy/fixed_phy.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/phy/fixed_phy.c b/drivers/net/phy/fixed_phy.c
index c649c101bbab..eb5167210681 100644
--- a/drivers/net/phy/fixed_phy.c
+++ b/drivers/net/phy/fixed_phy.c
@@ -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);
--
2.7.3
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH net 0/3] net: phy: fix of_node and device leaks
2016-11-16 14:20 [PATCH net 0/3] net: phy: fix of_node and device leaks Johan Hovold
` (2 preceding siblings ...)
2016-11-16 14:20 ` [PATCH net 3/3] net: phy: fixed_phy: fix of_node leak in fixed_phy_unregister Johan Hovold
@ 2016-11-17 17:05 ` David Miller
3 siblings, 0 replies; 5+ messages in thread
From: David Miller @ 2016-11-17 17:05 UTC (permalink / raw)
To: johan; +Cc: f.fainelli, robh+dt, frowand.list, netdev, linux-kernel
From: Johan Hovold <johan@kernel.org>
Date: Wed, 16 Nov 2016 15:20:35 +0100
> These patches fix a couple of of_node leaks in the fixed-link code and a
> device reference leak in a phy helper.
Series applied, thanks.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2016-11-17 17:25 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-16 14:20 [PATCH net 0/3] net: phy: fix of_node and device leaks Johan Hovold
2016-11-16 14:20 ` [PATCH net 1/3] of_mdio: fix node leak in of_phy_register_fixed_link error path Johan Hovold
2016-11-16 14:20 ` [PATCH net 2/3] of_mdio: fix device reference leak in of_phy_find_device Johan Hovold
2016-11-16 14:20 ` [PATCH net 3/3] net: phy: fixed_phy: fix of_node leak in fixed_phy_unregister Johan Hovold
2016-11-17 17:05 ` [PATCH net 0/3] net: phy: fix of_node and device leaks David Miller
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).