netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net] net: lan966x: add missing fwnode_handle_put() for ports node
@ 2023-01-12 16:13 Clément Léger
  2023-01-13 22:39 ` Alexander H Duyck
  2023-01-14  6:00 ` patchwork-bot+netdevbpf
  0 siblings, 2 replies; 3+ messages in thread
From: Clément Léger @ 2023-01-12 16:13 UTC (permalink / raw)
  To: Horatiu Vultur, UNGLinuxDriver, David S. Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni
  Cc: Clément Léger, netdev, linux-kernel

Since the "ethernet-ports" node is retrieved using
device_get_named_child_node(), it should be release after using it. Add
missing fwnode_handle_put() and move the code that retrieved the node
from device-tree to avoid complicated handling in case of error.

Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
 .../net/ethernet/microchip/lan966x/lan966x_main.c   | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
index cadde20505ba..580c91d24a52 100644
--- a/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
+++ b/drivers/net/ethernet/microchip/lan966x/lan966x_main.c
@@ -1043,11 +1043,6 @@ static int lan966x_probe(struct platform_device *pdev)
 		lan966x->base_mac[5] &= 0xf0;
 	}
 
-	ports = device_get_named_child_node(&pdev->dev, "ethernet-ports");
-	if (!ports)
-		return dev_err_probe(&pdev->dev, -ENODEV,
-				     "no ethernet-ports child found\n");
-
 	err = lan966x_create_targets(pdev, lan966x);
 	if (err)
 		return dev_err_probe(&pdev->dev, err,
@@ -1125,6 +1120,11 @@ static int lan966x_probe(struct platform_device *pdev)
 		}
 	}
 
+	ports = device_get_named_child_node(&pdev->dev, "ethernet-ports");
+	if (!ports)
+		return dev_err_probe(&pdev->dev, -ENODEV,
+				     "no ethernet-ports child found\n");
+
 	/* init switch */
 	lan966x_init(lan966x);
 	lan966x_stats_init(lan966x);
@@ -1162,6 +1162,8 @@ static int lan966x_probe(struct platform_device *pdev)
 			goto cleanup_ports;
 	}
 
+	fwnode_handle_put(ports);
+
 	lan966x_mdb_init(lan966x);
 	err = lan966x_fdb_init(lan966x);
 	if (err)
@@ -1191,6 +1193,7 @@ static int lan966x_probe(struct platform_device *pdev)
 	lan966x_fdb_deinit(lan966x);
 
 cleanup_ports:
+	fwnode_handle_put(ports);
 	fwnode_handle_put(portnp);
 
 	lan966x_cleanup_ports(lan966x);
-- 
2.39.0


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

* Re: [PATCH net] net: lan966x: add missing fwnode_handle_put() for ports node
  2023-01-12 16:13 [PATCH net] net: lan966x: add missing fwnode_handle_put() for ports node Clément Léger
@ 2023-01-13 22:39 ` Alexander H Duyck
  2023-01-14  6:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: Alexander H Duyck @ 2023-01-13 22:39 UTC (permalink / raw)
  To: Clément Léger, Horatiu Vultur, UNGLinuxDriver,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: netdev, linux-kernel

On Thu, 2023-01-12 at 17:13 +0100, Clément Léger wrote:
> Since the "ethernet-ports" node is retrieved using
> device_get_named_child_node(), it should be release after using it. Add
> missing fwnode_handle_put() and move the code that retrieved the node
> from device-tree to avoid complicated handling in case of error.
> 
> Signed-off-by: Clément Léger <clement.leger@bootlin.com>


You should probably add a fixes tag to this:
Fixes: db8bcaad5393 ("net: lan966x: add the basic lan966x driver")

Other than that the patch itself looks good to me.

Reviewed-by: Alexander Duyck <alexanderduyck@fb.com>

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

* Re: [PATCH net] net: lan966x: add missing fwnode_handle_put() for ports node
  2023-01-12 16:13 [PATCH net] net: lan966x: add missing fwnode_handle_put() for ports node Clément Léger
  2023-01-13 22:39 ` Alexander H Duyck
@ 2023-01-14  6:00 ` patchwork-bot+netdevbpf
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2023-01-14  6:00 UTC (permalink / raw)
  To: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2VyIDxjbGVtZW50LmxlZ2VyQGJvb3RsaW4uY29tPg==?=
  Cc: horatiu.vultur, UNGLinuxDriver, davem, edumazet, kuba, pabeni,
	netdev, linux-kernel

Hello:

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

On Thu, 12 Jan 2023 17:13:11 +0100 you wrote:
> Since the "ethernet-ports" node is retrieved using
> device_get_named_child_node(), it should be release after using it. Add
> missing fwnode_handle_put() and move the code that retrieved the node
> from device-tree to avoid complicated handling in case of error.
> 
> Signed-off-by: Clément Léger <clement.leger@bootlin.com>
> 
> [...]

Here is the summary with links:
  - [net] net: lan966x: add missing fwnode_handle_put() for ports node
    https://git.kernel.org/netdev/net/c/925f3deb45df

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] 3+ messages in thread

end of thread, other threads:[~2023-01-14  6:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-01-12 16:13 [PATCH net] net: lan966x: add missing fwnode_handle_put() for ports node Clément Léger
2023-01-13 22:39 ` Alexander H Duyck
2023-01-14  6: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).