All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] powerpc: fix unbalanced node refcount in check_kvm_guest()
@ 2021-09-28 12:45 Nathan Lynch
  2021-09-28 18:57 ` Tyrel Datwyler
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Nathan Lynch @ 2021-09-28 12:45 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: srikar, npiggin

When check_kvm_guest() succeeds in looking up a /hypervisor OF node, it
returns without performing a matching put for the lookup, leaving the
node's reference count elevated.

Add the necessary call to of_node_put(), rearranging the code slightly to
avoid repetition or goto.

Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Fixes: 107c55005fbd ("powerpc/pseries: Add KVM guest doorbell restrictions")
---
 arch/powerpc/kernel/firmware.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/kernel/firmware.c b/arch/powerpc/kernel/firmware.c
index c7022c41cc31..20328f72f9f2 100644
--- a/arch/powerpc/kernel/firmware.c
+++ b/arch/powerpc/kernel/firmware.c
@@ -31,11 +31,10 @@ int __init check_kvm_guest(void)
 	if (!hyper_node)
 		return 0;
 
-	if (!of_device_is_compatible(hyper_node, "linux,kvm"))
-		return 0;
-
-	static_branch_enable(&kvm_guest);
+	if (of_device_is_compatible(hyper_node, "linux,kvm"))
+		static_branch_enable(&kvm_guest);
 
+	of_node_put(hyper_node);
 	return 0;
 }
 core_initcall(check_kvm_guest); // before kvm_guest_init()
-- 
2.31.1


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

end of thread, other threads:[~2021-10-11 12:11 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-28 12:45 [PATCH] powerpc: fix unbalanced node refcount in check_kvm_guest() Nathan Lynch
2021-09-28 18:57 ` Tyrel Datwyler
2021-09-29  7:29 ` Srikar Dronamraju
2021-10-11 12:06 ` Michael Ellerman

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.