All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Srivatsa S. Bhat" <srivatsa@csail.mit.edu>
To: Liang He <windhl@126.com>,
	jgross@suse.com, virtualization@lists.linux-foundation.org
Cc: jailhouse-dev@googlegroups.com, mark.rutland@arm.com,
	jan.kiszka@siemens.com, andy.shevchenko@gmail.com,
	robh+dt@kernel.org, wangkelin2023@163.com,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Thomas Gleixner <tglx@linutronix.de>
Subject: Re: [PATCH] jailhouse: Hold reference returned from of_find_xxx API
Date: Thu, 15 Sep 2022 16:29:06 -0700	[thread overview]
Message-ID: <f7316f94-433f-d191-0379-423c22bec129@csail.mit.edu> (raw)
In-Reply-To: <20220915022343.4001331-1-windhl@126.com>


[ Adding author and reviewers of commit 63338a38db95 ]

On 9/14/22 7:23 PM, Liang He wrote:
> In jailhouse_paravirt(), we should hold the reference returned from
> of_find_compatible_node() which has increased the refcount and then
> call of_node_put() with it when done.
> 
> Fixes: 63338a38db95 ("jailhouse: Provide detection for non-x86 systems")
> Signed-off-by: Liang He <windhl@126.com>
> Signed-off-by: Kelin Wang <wangkelin2023@163.com>
> ---
>  include/linux/hypervisor.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/hypervisor.h b/include/linux/hypervisor.h
> index 9efbc54e35e5..7fe1e8c6211c 100644
> --- a/include/linux/hypervisor.h
> +++ b/include/linux/hypervisor.h
> @@ -27,7 +27,11 @@ static inline void hypervisor_pin_vcpu(int cpu)
>  
>  static inline bool jailhouse_paravirt(void)
>  {
> -	return of_find_compatible_node(NULL, NULL, "jailhouse,cell");
> +	struct device_node *np = of_find_compatible_node(NULL, NULL, "jailhouse,cell");
> +
> +	of_node_put(np);
> +
> +	return np;
>  }
>  

Thank you for the fix, but returning a pointer from a function with a
bool return type looks odd. Can we also fix that up please?


Regards,
Srivatsa
VMware Photon OS
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization

WARNING: multiple messages have this Message-ID (diff)
From: "Srivatsa S. Bhat" <srivatsa@csail.mit.edu>
To: Liang He <windhl@126.com>,
	jgross@suse.com, virtualization@lists.linux-foundation.org
Cc: wangkelin2023@163.com, jan.kiszka@siemens.com,
	Thomas Gleixner <tglx@linutronix.de>,
	jailhouse-dev@googlegroups.com, mark.rutland@arm.com,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	andy.shevchenko@gmail.com, robh+dt@kernel.org,
	Bjorn Helgaas <bhelgaas@google.com>
Subject: Re: [PATCH] jailhouse: Hold reference returned from of_find_xxx API
Date: Thu, 15 Sep 2022 16:29:06 -0700	[thread overview]
Message-ID: <f7316f94-433f-d191-0379-423c22bec129@csail.mit.edu> (raw)
In-Reply-To: <20220915022343.4001331-1-windhl@126.com>


[ Adding author and reviewers of commit 63338a38db95 ]

On 9/14/22 7:23 PM, Liang He wrote:
> In jailhouse_paravirt(), we should hold the reference returned from
> of_find_compatible_node() which has increased the refcount and then
> call of_node_put() with it when done.
> 
> Fixes: 63338a38db95 ("jailhouse: Provide detection for non-x86 systems")
> Signed-off-by: Liang He <windhl@126.com>
> Signed-off-by: Kelin Wang <wangkelin2023@163.com>
> ---
>  include/linux/hypervisor.h | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/include/linux/hypervisor.h b/include/linux/hypervisor.h
> index 9efbc54e35e5..7fe1e8c6211c 100644
> --- a/include/linux/hypervisor.h
> +++ b/include/linux/hypervisor.h
> @@ -27,7 +27,11 @@ static inline void hypervisor_pin_vcpu(int cpu)
>  
>  static inline bool jailhouse_paravirt(void)
>  {
> -	return of_find_compatible_node(NULL, NULL, "jailhouse,cell");
> +	struct device_node *np = of_find_compatible_node(NULL, NULL, "jailhouse,cell");
> +
> +	of_node_put(np);
> +
> +	return np;
>  }
>  

Thank you for the fix, but returning a pointer from a function with a
bool return type looks odd. Can we also fix that up please?


Regards,
Srivatsa
VMware Photon OS

  parent reply	other threads:[~2022-09-15 23:29 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20220915022343.4001331-1-windhl@126.com>
2022-09-15  7:00 ` [PATCH] jailhouse: Hold reference returned from of_find_xxx API Juergen Gross via Virtualization
2022-09-15 23:29 ` Srivatsa S. Bhat [this message]
2022-09-15 23:29   ` Srivatsa S. Bhat
2022-09-16  2:00   ` Liang He
2022-09-16  5:38     ` Andy Shevchenko
2022-09-16  5:38       ` Andy Shevchenko
2022-09-16  7:07       ` Liang He
2022-09-16  8:46         ` Andy Shevchenko
2022-09-16  8:46           ` Andy Shevchenko
2022-09-16  8:49           ` Liang He

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=f7316f94-433f-d191-0379-423c22bec129@csail.mit.edu \
    --to=srivatsa@csail.mit.edu \
    --cc=andy.shevchenko@gmail.com \
    --cc=bhelgaas@google.com \
    --cc=jailhouse-dev@googlegroups.com \
    --cc=jan.kiszka@siemens.com \
    --cc=jgross@suse.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=tglx@linutronix.de \
    --cc=virtualization@lists.linux-foundation.org \
    --cc=wangkelin2023@163.com \
    --cc=windhl@126.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.