jailhouse: Hold reference returned from of_find_xxx API
Subsystems (2)
A message that is not in the archive (sent off-list or not yet received): [email protected]
Juergen Gross via Virtualization
Reviewed-by Juergen GrossQuoted 7 lines · Liang He
In
jailhouse_paravirt(), we should hold the reference returned fromof_find_compatible_node()which has increased the refcount and then callof_node_put()with it when done.Fixes 63338a38db95 ("jailhouse: Provide detection for non-x86 systems")Signed-off-by Liang He <[email protected]>Signed-off-by Kelin Wang <[email protected]>
Juergen
_______________________________________________
Virtualization mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
[ Adding author and reviewers of commit 63338a38db95 ]
Quoted 17 lines · Liang He
In
jailhouse_paravirt(), we should hold the reference returned fromof_find_compatible_node()which has increased the refcount and then callof_node_put()with it when done.Fixes 63338a38db95 ("jailhouse: Provide detection for non-x86 systems")Signed-off-by Liang He <[email protected]>Signed-off-by Kelin Wang <[email protected]>--- include/linux/hypervisor.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)include/linux/hypervisor.h +0
-0@@ -27,7 +27,11 @@ static inline void hypervisor_pin_vcpu(int cpu)
include/linux/hypervisor.h static inline void hypervisor_pin_vcpu(int cpu) · line 36
Quoted 10 lines
include/linux/hypervisor.h +5
-1static 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
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
Quoted 21 lines · Srivatsa S. Bhat
[ Adding author and reviewers of commit
63338a38db95]Quoted 17 lines · Liang He
In
jailhouse_paravirt(), we should hold the reference returned fromof_find_compatible_node()which has increased the refcount and then callof_node_put()with it when done.Fixes 63338a38db95 ("jailhouse: Provide detection for non-x86 systems")Signed-off-by Liang He <[email protected]>Signed-off-by Kelin Wang <[email protected]>--- include/linux/hypervisor.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)include/linux/hypervisor.h +0
-0@@ -27,7 +27,11 @@ static inline void hypervisor_pin_vcpu(int cpu)
Quoted 14 lines
include/linux/hypervisor.h static inline void hypervisor_pin_vcpu(int cpu) · line 36
Quoted 10 lines
include/linux/hypervisor.h +5
-1static 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);
Quoted 4 lines
Regards,
Srivatsa
VMware Photon OS
Quoted 2 lines · Liang He
Quoted 1 line · Srivatsa S. Bhat
On 9/14/22 7:23 PM, Liang He wrote:
..
Quoted 16 lines
Quoted 4 lines
Quoted 4 lines
static inline bool
jailhouse_paravirt(void)
{(quoted diff) +1
-1- return of_find_compatible_node(NULL, NULL, "jailhouse,cell"); + struct device_node *np = of_find_compatible_node(NULL, NULL, "jailhouse,cell");Quoted 9 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+ + 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:
Review
Quoted 6 lines
(quoted diff) +5
-1- 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);
This will be opposite to the above. Perhaps you wanted
return !!np;
Also possible (but why?)
return np ? true : false;
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 22 lines · Andy Shevchenko
Quoted 2 lines · Liang He
Quoted 1 line · Srivatsa S. Bhat
On 9/14/22 7:23 PM, Liang He wrote:
..
Quoted 16 lines
Quoted 4 lines
Quoted 4 lines
static inline bool
jailhouse_paravirt(void)
{(quoted diff) +1
-1- return of_find_compatible_node(NULL, NULL, "jailhouse,cell"); + struct device_node *np = of_find_compatible_node(NULL, NULL, "jailhouse,cell");Quoted 9 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+ + 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:
Quoted 9 lines
Review
Quoted 6 lines
(quoted diff) +5
-1- 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);This will be opposite to the above. Perhaps you wanted
Sorry, I wanted to use 'np!=NULL'
Quoted 7 lines
return !!np;
Also possible (but why?)
return np ? true : false;
So, can I chose 'return np?true: false;' as the final patch?
Thanks,
Liang
Quoted 2 lines
-- >With Best Regards,
Andy Shevchenko
Quoted 4 lines · Liang He
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Liang He
Quoted 1 line · Srivatsa S. Bhat
On 9/14/22 7:23 PM, Liang He wrote:
...
Quoted 26 lines
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
static inline bool
jailhouse_paravirt(void)
{(quoted diff) +1
-1- return of_find_compatible_node(NULL, NULL, "jailhouse,cell"); + struct device_node *np = of_find_compatible_node(NULL, NULL, "jailhouse,cell");Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+ + 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:
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +5
-1- 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);This will be opposite to the above. Perhaps you wanted
Sorry, I wanted to use 'np!=NULL'
Quoted 7 lines
Quoted 5 lines
return !!np;
Also possible (but why?)
return np ? true : false;
So, can I chose 'return np?true: false;' as the final patch?
Of course you can, it's up to the maintainer(s) what to accept.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Quoted 36 lines · Andy Shevchenko
Quoted 4 lines · Liang He
Quoted 3 lines · Andy Shevchenko
Quoted 2 lines · Liang He
Quoted 1 line · Srivatsa S. Bhat
On 9/14/22 7:23 PM, Liang He wrote:
...
Quoted 28 lines
Quoted 15 lines
Quoted 15 lines
Quoted 4 lines
Quoted 4 lines
static inline bool
jailhouse_paravirt(void)
{(quoted diff) +1
-1- return of_find_compatible_node(NULL, NULL, "jailhouse,cell"); + struct device_node *np = of_find_compatible_node(NULL, NULL, "jailhouse,cell");Quoted 8 lines
Review
Quoted 5 lines
(quoted diff) +4
-0+ + 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:
Quoted 8 lines
Review
Quoted 6 lines
(quoted diff) +5
-1- 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);This will be opposite to the above. Perhaps you wanted
Sorry, I wanted to use 'np!=NULL'
Quoted 2 lines
return !!np;
Quoted 11 lines
Quoted 5 lines
Quoted 3 lines
Also possible (but why?)
return np ? true : false;
So, can I chose 'return np?true: false;' as the final patch?
Of course you can, it's up to the maintainer(s) what to accept.
Signature · 2 lines
With Best Regards, Andy Shevchenko
Thanks, I will do it now.