diff mbox series

arm: mach-omap2: omap4-common: Fix refcount leak bug

Message ID 20220617035548.4003393-1-windhl@126.com (mailing list archive)
State New, archived
Headers show
Series arm: mach-omap2: omap4-common: Fix refcount leak bug | expand

Commit Message

Liang He June 17, 2022, 3:55 a.m. UTC
In omap4_sram_init(), of_find_compatible_node() will return a node
pointer with refcount incremented. We should use of_node_put() when
it is not used anymore.

Signed-off-by: Liang He <windhl@126.com>
---
 arch/arm/mach-omap2/omap4-common.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Tony Lindgren June 28, 2022, 4:38 a.m. UTC | #1
* Liang He <windhl@126.com> [220617 06:51]:
> In omap4_sram_init(), of_find_compatible_node() will return a node
> pointer with refcount incremented. We should use of_node_put() when
> it is not used anymore.
> 
> Signed-off-by: Liang He <windhl@126.com>
> ---
>  arch/arm/mach-omap2/omap4-common.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/arm/mach-omap2/omap4-common.c b/arch/arm/mach-omap2/omap4-common.c
> index 6d1eb4eefefe..e981bf57e64f 100644
> --- a/arch/arm/mach-omap2/omap4-common.c
> +++ b/arch/arm/mach-omap2/omap4-common.c
> @@ -135,6 +135,7 @@ static int __init omap4_sram_init(void)
>  		pr_warn("%s:Unable to allocate sram needed to handle errata I688\n",
>  			__func__);
>  	sram_pool = of_gen_pool_get(np, "sram", 0);
> +	of_node_put(np);
>  	if (!sram_pool)
>  		pr_warn("%s:Unable to get sram pool needed to handle errata I688\n",
>  			__func__);

Here too sram_pool is used aftger of_node_put().

Regards,

Tony
Liang He June 28, 2022, 5:52 a.m. UTC | #2
At 2022-06-28 12:38:49, "Tony Lindgren" <tony@atomide.com> wrote:
>* Liang He <windhl@126.com> [220617 06:51]:
>> In omap4_sram_init(), of_find_compatible_node() will return a node
>> pointer with refcount incremented. We should use of_node_put() when
>> it is not used anymore.
>> 
>> Signed-off-by: Liang He <windhl@126.com>
>> ---
>>  arch/arm/mach-omap2/omap4-common.c | 1 +
>>  1 file changed, 1 insertion(+)
>> 
>> diff --git a/arch/arm/mach-omap2/omap4-common.c b/arch/arm/mach-omap2/omap4-common.c
>> index 6d1eb4eefefe..e981bf57e64f 100644
>> --- a/arch/arm/mach-omap2/omap4-common.c
>> +++ b/arch/arm/mach-omap2/omap4-common.c
>> @@ -135,6 +135,7 @@ static int __init omap4_sram_init(void)
>>  		pr_warn("%s:Unable to allocate sram needed to handle errata I688\n",
>>  			__func__);
>>  	sram_pool = of_gen_pool_get(np, "sram", 0);
>> +	of_node_put(np);
>>  	if (!sram_pool)
>>  		pr_warn("%s:Unable to get sram pool needed to handle errata I688\n",
>>  			__func__);
>
>Here too sram_pool is used aftger of_node_put().
>
>Regards,
>
>Tony

Thanks, Tony.

I will send a new patch to fix the order problem.

Liang
diff mbox series

Patch

diff --git a/arch/arm/mach-omap2/omap4-common.c b/arch/arm/mach-omap2/omap4-common.c
index 6d1eb4eefefe..e981bf57e64f 100644
--- a/arch/arm/mach-omap2/omap4-common.c
+++ b/arch/arm/mach-omap2/omap4-common.c
@@ -135,6 +135,7 @@  static int __init omap4_sram_init(void)
 		pr_warn("%s:Unable to allocate sram needed to handle errata I688\n",
 			__func__);
 	sram_pool = of_gen_pool_get(np, "sram", 0);
+	of_node_put(np);
 	if (!sram_pool)
 		pr_warn("%s:Unable to get sram pool needed to handle errata I688\n",
 			__func__);