Skip to content

Commit ddd95eb

Browse files
nathanlynchgregkh
authored andcommitted
powerpc: fix unbalanced node refcount in check_kvm_guest()
[ Upstream commit 56537fa ] 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. Fixes: 107c550 ("powerpc/pseries: Add KVM guest doorbell restrictions") Signed-off-by: Nathan Lynch <[email protected]> Reviewed-by: Srikar Dronamraju <[email protected]> Reviewed-by: Tyrel Datwyler <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Sasha Levin <[email protected]>
1 parent 2af0702 commit ddd95eb

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

arch/powerpc/kernel/firmware.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,10 @@ int __init check_kvm_guest(void)
3131
if (!hyper_node)
3232
return 0;
3333

34-
if (!of_device_is_compatible(hyper_node, "linux,kvm"))
35-
return 0;
36-
37-
static_branch_enable(&kvm_guest);
34+
if (of_device_is_compatible(hyper_node, "linux,kvm"))
35+
static_branch_enable(&kvm_guest);
3836

37+
of_node_put(hyper_node);
3938
return 0;
4039
}
4140
core_initcall(check_kvm_guest); // before kvm_guest_init()

0 commit comments

Comments
 (0)