All of lore.kernel.org
 help / color / mirror / Atom feed
From: Srikar Dronamraju <srikar@linux.vnet.ibm.com>
To: Nathan Lynch <nathanl@linux.ibm.com>
Cc: linuxppc-dev@lists.ozlabs.org, npiggin@gmail.com
Subject: Re: [PATCH] powerpc: fix unbalanced node refcount in check_kvm_guest()
Date: Wed, 29 Sep 2021 12:59:25 +0530	[thread overview]
Message-ID: <20210929072925.GE2004@linux.vnet.ibm.com> (raw)
In-Reply-To: <20210928124550.132020-1-nathanl@linux.ibm.com>

* Nathan Lynch <nathanl@linux.ibm.com> [2021-09-28 07:45:50]:

> 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.
> 

Looks good to me.

I do see few other cases where we call of_find_node calls without
of_node_put().

Some of them that I saw were in

find_legacy_serial_ports()  in  arch/powerpc/kernel/legacy_serial.c
proc_ppc64_create in arch/powerpc/proc/powerpc.c
update_events_in_group in arch/powerpc/perf/imc-pmu.c
cell_iommu_init_disabled in arch/powerpc/platforms/cell/iommu.c
cell_publish_devices in arch/powerpc/platforms/cell/setup.c
spufs_init_isolated_loader in arch/powerpc/platforms/cell/spufs/inode.c
holly_init_pci / holly_restart and holly_init_IRQ in arch/powerpc/platforms/embedded6xx/holly.c

Reviewed-by: Srikar Dronamraju <srikar@linux.vnet.ibm.com>

> 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
> 

-- 
Thanks and Regards
Srikar Dronamraju

  parent reply	other threads:[~2021-09-29  7:30 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2021-10-11 12:06 ` Michael Ellerman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210929072925.GE2004@linux.vnet.ibm.com \
    --to=srikar@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=nathanl@linux.ibm.com \
    --cc=npiggin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.