linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net: altera: Fix refcount leak in altera_tse_mdio_create
@ 2022-06-07  4:11 Miaoqian Lin
  2022-06-09  4:00 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Miaoqian Lin @ 2022-06-07  4:11 UTC (permalink / raw)
  To: Joyce Ooi, David S. Miller, Eric Dumazet, Jakub Kicinski,
	Paolo Abeni, Vince Bridgers, netdev, linux-kernel
  Cc: linmq006

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.

Fixes: bbd2190ce96d ("Altera TSE: Add main and header file for Altera Ethernet Driver")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/net/ethernet/altera/altera_tse_main.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/altera/altera_tse_main.c b/drivers/net/ethernet/altera/altera_tse_main.c
index a3816264c35c..8c5828582c21 100644
--- a/drivers/net/ethernet/altera/altera_tse_main.c
+++ b/drivers/net/ethernet/altera/altera_tse_main.c
@@ -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;
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] net: altera: Fix refcount leak in altera_tse_mdio_create
  2022-06-07  4:11 [PATCH] net: altera: Fix refcount leak in altera_tse_mdio_create Miaoqian Lin
@ 2022-06-09  4:00 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-06-09  4:00 UTC (permalink / raw)
  To: Miaoqian Lin
  Cc: joyce.ooi, davem, edumazet, kuba, pabeni, vbridgers2013, netdev,
	linux-kernel

Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

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 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.
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-06-09  4:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-07  4:11 [PATCH] net: altera: Fix refcount leak in altera_tse_mdio_create Miaoqian Lin
2022-06-09  4:00 ` patchwork-bot+netdevbpf

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).