public inbox for linux-arm-kernel@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH] firmware: psci: Fix refcount leak in psci_dt_init
@ 2025-03-18 15:17 Miaoqian Lin
  2025-03-19 10:28 ` Gavin Shan
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Miaoqian Lin @ 2025-03-18 15:17 UTC (permalink / raw)
  To: Mark Rutland, Lorenzo Pieralisi, Will Deacon, Hanjun Guo,
	Catalin Marinas, linux-arm-kernel, linux-kernel
  Cc: linmq006

Fix a reference counter leak in psci_dt_init() where of_node_put(np) was
missing after of_find_matching_node_and_match() when np is unavailable.

Fixes: bff60792f994 ("arm64: psci: factor invocation code to drivers")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
 drivers/firmware/psci/psci.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/firmware/psci/psci.c b/drivers/firmware/psci/psci.c
index a1ebbe9b73b1..38ca190d4a22 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -804,8 +804,10 @@ int __init psci_dt_init(void)
 
 	np = of_find_matching_node_and_match(NULL, psci_of_match, &matched_np);
 
-	if (!np || !of_device_is_available(np))
+	if (!np || !of_device_is_available(np)) {
+		of_node_put(np);
 		return -ENODEV;
+	}
 
 	init_fn = (psci_initcall_t)matched_np->data;
 	ret = init_fn(np);
-- 
2.39.5 (Apple Git-154)



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

end of thread, other threads:[~2025-04-29 20:45 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-18 15:17 [PATCH] firmware: psci: Fix refcount leak in psci_dt_init Miaoqian Lin
2025-03-19 10:28 ` Gavin Shan
2025-03-19 10:46   ` Sudeep Holla
2025-03-19 11:12     ` Mark Rutland
2025-03-19 11:39       ` Sudeep Holla
2025-03-19 11:23 ` Mark Rutland
2025-03-19 23:30 ` Gavin Shan
2025-04-29 20:27 ` Will Deacon

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