mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] psci: Fix refcount leak in psci_dt_init
@ 2022-06-01 13:11 Miaoqian Lin
  0 siblings, 0 replies; only message in thread
From: Miaoqian Lin @ 2022-06-01 13:11 UTC (permalink / raw)
  To: Mark Rutland, Lorenzo Pieralisi, Thierry Reding, Arnd Bergmann,
	linux-arm-kernel, linux-kernel
  Cc: linmq006

of_find_matching_node_and_match() returns a node pointer with refcount
incremented, we should use of_node_put() on it when not need anymore.
When of_device_is_available() fails, call of_node_put() to release the
refcount. And of_node_put() will checks NULL pointer.

Fixes: d09a0011ec0d ("drivers: psci: Allow PSCI node to be disabled")
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 cfb448eabdaa..ec888aba57ff 100644
--- a/drivers/firmware/psci/psci.c
+++ b/drivers/firmware/psci/psci.c
@@ -619,8 +619,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.25.1


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2022-06-01 13:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-01 13:11 [PATCH] psci: Fix refcount leak in psci_dt_init Miaoqian Lin

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®