mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v2] soc: atmel: fix device_node release in atmel_soc_device_init()
@ 2024-10-31 12:33 Javier Carrasco
  2024-12-08 15:52 ` Claudiu Beznea
  0 siblings, 1 reply; 2+ messages in thread
From: Javier Carrasco @ 2024-10-31 12:33 UTC (permalink / raw)
  To: Nicolas Ferre, Alexandre Belloni, Claudiu Beznea, Sudeep Holla
  Cc: linux-arm-kernel, linux-kernel, Javier Carrasco

A device_node acquired via of_find_node_by_path() requires explicit
calls to of_node_put() when it is no longer needed to avoid leaking the
resource.

Instead of adding the missing calls to of_node_put() in all execution
paths, use the cleanup attribute for 'np' by means of the __free()
macro, which automatically calls of_node_put() when the variable goes
out of scope.

Fixes: 960ddf70cc11 ("drivers: soc: atmel: Avoid calling at91_soc_init on non AT91 SoCs")
Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>
---
Changes in v2:
- Squash patches for mainline solution without intermediate steps.
- Link to v1: https://lore.kernel.org/r/20241030-soc-atmel-soc-cleanup-v1-0-32b9e0773b14@gmail.com
---
 drivers/soc/atmel/soc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/soc/atmel/soc.c b/drivers/soc/atmel/soc.c
index 2a42b28931c9..298b542dd1c0 100644
--- a/drivers/soc/atmel/soc.c
+++ b/drivers/soc/atmel/soc.c
@@ -399,7 +399,7 @@ static const struct of_device_id at91_soc_allowed_list[] __initconst = {
 
 static int __init atmel_soc_device_init(void)
 {
-	struct device_node *np = of_find_node_by_path("/");
+	struct device_node *np __free(device_node) = of_find_node_by_path("/");
 
 	if (!of_match_node(at91_soc_allowed_list, np))
 		return 0;

---
base-commit: 86e3904dcdc7e70e3257fc1de294a1b75f3d8d04
change-id: 20241030-soc-atmel-soc-cleanup-8fcf3029bb28

Best regards,
-- 
Javier Carrasco <javier.carrasco.cruz@gmail.com>


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

* Re: [PATCH v2] soc: atmel: fix device_node release in atmel_soc_device_init()
  2024-10-31 12:33 [PATCH v2] soc: atmel: fix device_node release in atmel_soc_device_init() Javier Carrasco
@ 2024-12-08 15:52 ` Claudiu Beznea
  0 siblings, 0 replies; 2+ messages in thread
From: Claudiu Beznea @ 2024-12-08 15:52 UTC (permalink / raw)
  To: Javier Carrasco, Nicolas Ferre, Alexandre Belloni, Sudeep Holla
  Cc: linux-arm-kernel, linux-kernel



On 31.10.2024 14:33, Javier Carrasco wrote:
> A device_node acquired via of_find_node_by_path() requires explicit
> calls to of_node_put() when it is no longer needed to avoid leaking the
> resource.
> 
> Instead of adding the missing calls to of_node_put() in all execution
> paths, use the cleanup attribute for 'np' by means of the __free()
> macro, which automatically calls of_node_put() when the variable goes
> out of scope.
> 
> Fixes: 960ddf70cc11 ("drivers: soc: atmel: Avoid calling at91_soc_init on non AT91 SoCs")
> Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com>

Applied to at91-soc, thanks!

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

end of thread, other threads:[~2024-12-08 15:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-31 12:33 [PATCH v2] soc: atmel: fix device_node release in atmel_soc_device_init() Javier Carrasco
2024-12-08 15:52 ` Claudiu Beznea

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®