All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ARM: OMAP2+: Hold reference returned from of_find_xxx API
@ 2022-09-15  1:42 ` Liang He
  0 siblings, 0 replies; 6+ messages in thread
From: Liang He @ 2022-09-15  1:42 UTC (permalink / raw)
  To: tony, linux, linux-omap, linux-arm-kernel; +Cc: windhl, chenmengda2009

In omap4_twl_init(), 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: ccd369455a23 ("ARM: OMAP2+: Remove bogus warnings for machines without twl PMIC")
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Mengda Chen <chenmengda2009@163.com>
---
 arch/arm/mach-omap2/omap_twl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
index d4dab041324d..07b5f17066ce 100644
--- a/arch/arm/mach-omap2/omap_twl.c
+++ b/arch/arm/mach-omap2/omap_twl.c
@@ -213,11 +213,13 @@ static struct omap_voltdm_pmic omap4_core_pmic = {
 int __init omap4_twl_init(void)
 {
 	struct voltagedomain *voltdm;
+	struct device_node *np;
 
 	if (!cpu_is_omap44xx() ||
-	    of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
+	    (np = of_find_compatible_node(NULL, NULL, "motorola,cpcap"))) {
+		of_node_put(np);
 		return -ENODEV;
-
+	}
 	voltdm = voltdm_lookup("mpu");
 	omap_voltage_register_pmic(voltdm, &omap4_mpu_pmic);
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH] ARM: OMAP2+: Hold reference returned from of_find_xxx API
@ 2022-09-15  1:42 ` Liang He
  0 siblings, 0 replies; 6+ messages in thread
From: Liang He @ 2022-09-15  1:42 UTC (permalink / raw)
  To: tony, linux, linux-omap, linux-arm-kernel; +Cc: windhl, chenmengda2009

In omap4_twl_init(), 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: ccd369455a23 ("ARM: OMAP2+: Remove bogus warnings for machines without twl PMIC")
Signed-off-by: Liang He <windhl@126.com>
Signed-off-by: Mengda Chen <chenmengda2009@163.com>
---
 arch/arm/mach-omap2/omap_twl.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
index d4dab041324d..07b5f17066ce 100644
--- a/arch/arm/mach-omap2/omap_twl.c
+++ b/arch/arm/mach-omap2/omap_twl.c
@@ -213,11 +213,13 @@ static struct omap_voltdm_pmic omap4_core_pmic = {
 int __init omap4_twl_init(void)
 {
 	struct voltagedomain *voltdm;
+	struct device_node *np;
 
 	if (!cpu_is_omap44xx() ||
-	    of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
+	    (np = of_find_compatible_node(NULL, NULL, "motorola,cpcap"))) {
+		of_node_put(np);
 		return -ENODEV;
-
+	}
 	voltdm = voltdm_lookup("mpu");
 	omap_voltage_register_pmic(voltdm, &omap4_mpu_pmic);
 
-- 
2.25.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH] ARM: OMAP2+: Hold reference returned from of_find_xxx API
  2022-09-15  1:42 ` Liang He
@ 2022-09-15 11:29   ` Russell King (Oracle)
  -1 siblings, 0 replies; 6+ messages in thread
From: Russell King (Oracle) @ 2022-09-15 11:29 UTC (permalink / raw)
  To: Liang He; +Cc: tony, linux-omap, linux-arm-kernel, chenmengda2009

On Thu, Sep 15, 2022 at 09:42:58AM +0800, Liang He wrote:
> In omap4_twl_init(), 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: ccd369455a23 ("ARM: OMAP2+: Remove bogus warnings for machines without twl PMIC")
> Signed-off-by: Liang He <windhl@126.com>
> Signed-off-by: Mengda Chen <chenmengda2009@163.com>
> ---
>  arch/arm/mach-omap2/omap_twl.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
> index d4dab041324d..07b5f17066ce 100644
> --- a/arch/arm/mach-omap2/omap_twl.c
> +++ b/arch/arm/mach-omap2/omap_twl.c
> @@ -213,11 +213,13 @@ static struct omap_voltdm_pmic omap4_core_pmic = {
>  int __init omap4_twl_init(void)
>  {
>  	struct voltagedomain *voltdm;
> +	struct device_node *np;
>  
>  	if (!cpu_is_omap44xx() ||
> -	    of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
> +	    (np = of_find_compatible_node(NULL, NULL, "motorola,cpcap"))) {
> +		of_node_put(np);

This is buggy - if cpu_is_omap44xx() is false, then np will not be
initialised. The simple solution is to initialise np to NULL.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH] ARM: OMAP2+: Hold reference returned from of_find_xxx API
@ 2022-09-15 11:29   ` Russell King (Oracle)
  0 siblings, 0 replies; 6+ messages in thread
From: Russell King (Oracle) @ 2022-09-15 11:29 UTC (permalink / raw)
  To: Liang He; +Cc: tony, linux-omap, linux-arm-kernel, chenmengda2009

On Thu, Sep 15, 2022 at 09:42:58AM +0800, Liang He wrote:
> In omap4_twl_init(), 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: ccd369455a23 ("ARM: OMAP2+: Remove bogus warnings for machines without twl PMIC")
> Signed-off-by: Liang He <windhl@126.com>
> Signed-off-by: Mengda Chen <chenmengda2009@163.com>
> ---
>  arch/arm/mach-omap2/omap_twl.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
> index d4dab041324d..07b5f17066ce 100644
> --- a/arch/arm/mach-omap2/omap_twl.c
> +++ b/arch/arm/mach-omap2/omap_twl.c
> @@ -213,11 +213,13 @@ static struct omap_voltdm_pmic omap4_core_pmic = {
>  int __init omap4_twl_init(void)
>  {
>  	struct voltagedomain *voltdm;
> +	struct device_node *np;
>  
>  	if (!cpu_is_omap44xx() ||
> -	    of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
> +	    (np = of_find_compatible_node(NULL, NULL, "motorola,cpcap"))) {
> +		of_node_put(np);

This is buggy - if cpu_is_omap44xx() is false, then np will not be
initialised. The simple solution is to initialise np to NULL.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re:Re: [PATCH] ARM: OMAP2+: Hold reference returned from of_find_xxx API
  2022-09-15 11:29   ` Russell King (Oracle)
@ 2022-09-15 12:41     ` Liang He
  -1 siblings, 0 replies; 6+ messages in thread
From: Liang He @ 2022-09-15 12:41 UTC (permalink / raw)
  To: Russell King (Oracle); +Cc: tony, linux-omap, linux-arm-kernel, chenmengda2009




At 2022-09-15 19:29:58, "Russell King (Oracle)" <linux@armlinux.org.uk> wrote:
>On Thu, Sep 15, 2022 at 09:42:58AM +0800, Liang He wrote:
>> In omap4_twl_init(), 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: ccd369455a23 ("ARM: OMAP2+: Remove bogus warnings for machines without twl PMIC")
>> Signed-off-by: Liang He <windhl@126.com>
>> Signed-off-by: Mengda Chen <chenmengda2009@163.com>
>> ---
>>  arch/arm/mach-omap2/omap_twl.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>> 
>> diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
>> index d4dab041324d..07b5f17066ce 100644
>> --- a/arch/arm/mach-omap2/omap_twl.c
>> +++ b/arch/arm/mach-omap2/omap_twl.c
>> @@ -213,11 +213,13 @@ static struct omap_voltdm_pmic omap4_core_pmic = {
>>  int __init omap4_twl_init(void)
>>  {
>>  	struct voltagedomain *voltdm;
>> +	struct device_node *np;
>>  
>>  	if (!cpu_is_omap44xx() ||
>> -	    of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
>> +	    (np = of_find_compatible_node(NULL, NULL, "motorola,cpcap"))) {
>> +		of_node_put(np);
>
>This is buggy - if cpu_is_omap44xx() is false, then np will not be
>initialised. The simple solution is to initialise np to NULL.
>

Thanks, I will send a new version soon.

Liang

>-- 
>RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
>FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re:Re: [PATCH] ARM: OMAP2+: Hold reference returned from of_find_xxx API
@ 2022-09-15 12:41     ` Liang He
  0 siblings, 0 replies; 6+ messages in thread
From: Liang He @ 2022-09-15 12:41 UTC (permalink / raw)
  To: Russell King (Oracle); +Cc: tony, linux-omap, linux-arm-kernel, chenmengda2009




At 2022-09-15 19:29:58, "Russell King (Oracle)" <linux@armlinux.org.uk> wrote:
>On Thu, Sep 15, 2022 at 09:42:58AM +0800, Liang He wrote:
>> In omap4_twl_init(), 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: ccd369455a23 ("ARM: OMAP2+: Remove bogus warnings for machines without twl PMIC")
>> Signed-off-by: Liang He <windhl@126.com>
>> Signed-off-by: Mengda Chen <chenmengda2009@163.com>
>> ---
>>  arch/arm/mach-omap2/omap_twl.c | 6 ++++--
>>  1 file changed, 4 insertions(+), 2 deletions(-)
>> 
>> diff --git a/arch/arm/mach-omap2/omap_twl.c b/arch/arm/mach-omap2/omap_twl.c
>> index d4dab041324d..07b5f17066ce 100644
>> --- a/arch/arm/mach-omap2/omap_twl.c
>> +++ b/arch/arm/mach-omap2/omap_twl.c
>> @@ -213,11 +213,13 @@ static struct omap_voltdm_pmic omap4_core_pmic = {
>>  int __init omap4_twl_init(void)
>>  {
>>  	struct voltagedomain *voltdm;
>> +	struct device_node *np;
>>  
>>  	if (!cpu_is_omap44xx() ||
>> -	    of_find_compatible_node(NULL, NULL, "motorola,cpcap"))
>> +	    (np = of_find_compatible_node(NULL, NULL, "motorola,cpcap"))) {
>> +		of_node_put(np);
>
>This is buggy - if cpu_is_omap44xx() is false, then np will not be
>initialised. The simple solution is to initialise np to NULL.
>

Thanks, I will send a new version soon.

Liang

>-- 
>RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
>FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2022-09-15 13:13 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-09-15  1:42 [PATCH] ARM: OMAP2+: Hold reference returned from of_find_xxx API Liang He
2022-09-15  1:42 ` Liang He
2022-09-15 11:29 ` Russell King (Oracle)
2022-09-15 11:29   ` Russell King (Oracle)
2022-09-15 12:41   ` Liang He
2022-09-15 12:41     ` Liang He

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.