net: altera: Fix refcount leak in altera_tse_mdio_create
Subsystems (3)
PATCH 1/1 net: altera: Fix refcount leak in altera_tse_mdio_create
Every iteration of for_each_child_of_node() decrements the reference count of the previous node.
When break from a for_each_child_of_node() loop,
we need to explicitly call of_node_put() on the child node when not need anymore.
Add missing of_node_put() to avoid refcount leak.
--- drivers/net/ethernet/altera/altera_tse_main.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/net/ethernet/altera/altera_tse_main.c +5 -1
@@ -163,7 +163,8 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id) mdio =mdiobus_alloc ();if (mdio ==NULL ) {netdev_err (dev,"Error allocating MDIO bus\n" ); -return -ENOMEM ; + ret = -ENOMEM ; + goto put_node; } mdio->name =ALTERA_TSE_RESOURCE_NAME ;
@@ -180,6 +181,7 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id) mdio->id); goto out_free_mdio; } +of_node_put (mdio_node);if (netif_msg_drv (priv))netdev_info (dev,"MDIO bus %s: created\n" , mdio->id);
@@ -189,6 +191,8 @@ static int altera_tse_mdio_create(struct net_device *dev, unsigned int id) out_free_mdio:mdiobus_free (mdio); mdio =NULL ; +put_node: +of_node_put (mdio_node);return ret; }
Signature · 1 line
2.25.1
This patch was applied to netdev/net.git (master) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (master)
by Jakub Kicinski <[email protected]>:
Quoted 8 lines · On Tue, 7 Jun 2022 08:11:43 +0400 you wrote:
Every iteration of
for_each_child_of_node()decrements the reference count of the previous node.
When break from afor_each_child_of_node()loop,
we need to explicitly callof_node_put()on the child node when not need anymore.
Add missingof_node_put()to avoid refcount leak.[...]
Here is the summary with links:
- net: altera: Fix refcount leak in altera_tse_mdio_create
https://git.kernel.org/netdev/net/c/11ec18b1d8d9
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html