At 2022-09-16 07:29:06, "Srivatsa S. Bhat" <srivatsa@xxxxxxxxxxxxx> wrote: > >[ 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@xxxxxxx> >> Signed-off-by: Kelin Wang <wangkelin2023@xxxxxxx> >> --- >> 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? > Thanks for your review, how about following patch: - 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==NULL); > >Regards, >Srivatsa >VMware Photon OS