linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] mfd: max77620: Add of_node_put() before return
       [not found] <20190709173132.13886-1-nishkadg.linux@gmail.com>
@ 2019-07-25 12:15 ` Lee Jones
  2019-07-26  8:13   ` Nishka Dasgupta
  0 siblings, 1 reply; 2+ messages in thread
From: Lee Jones @ 2019-07-25 12:15 UTC (permalink / raw)
  To: Nishka Dasgupta; +Cc: linux-kernel

On Tue, 09 Jul 2019, Nishka Dasgupta wrote:

> Each iteration of for_each_child_of_node puts the previous node, but in
> the case of a return from the middle of the loop, there is no put, thus
> causing a memory leak. Hence add an of_node_put before the return.
> Issue found with Coccinelle.
> 
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---
>  drivers/mfd/max77620.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)

Ah, I've just seen that you didn't send this to the list.

When submitting patches upstream, you must CC at least one list.

Usually people CC LKML as a matter of course.

I've CC'ed LMKL here and applied the patch.

> diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c
> index 0c28965fcc6a..a851ff473a44 100644
> --- a/drivers/mfd/max77620.c
> +++ b/drivers/mfd/max77620.c
> @@ -416,8 +416,10 @@ static int max77620_initialise_fps(struct max77620_chip *chip)
>  
>  	for_each_child_of_node(fps_np, fps_child) {
>  		ret = max77620_config_fps(chip, fps_child);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			of_node_put(fps_child);
>  			return ret;
> +		}
>  	}
>  
>  	config = chip->enable_global_lpm ? MAX77620_ONOFFCNFG2_SLP_LPM_MSK : 0;

-- 
Lee Jones [李琼斯]
Linaro Services Technical Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

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

* Re: [PATCH] mfd: max77620: Add of_node_put() before return
  2019-07-25 12:15 ` [PATCH] mfd: max77620: Add of_node_put() before return Lee Jones
@ 2019-07-26  8:13   ` Nishka Dasgupta
  0 siblings, 0 replies; 2+ messages in thread
From: Nishka Dasgupta @ 2019-07-26  8:13 UTC (permalink / raw)
  To: Lee Jones; +Cc: linux-kernel

On 25/07/19 5:45 PM, Lee Jones wrote:
> On Tue, 09 Jul 2019, Nishka Dasgupta wrote:
> 
>> Each iteration of for_each_child_of_node puts the previous node, but in
>> the case of a return from the middle of the loop, there is no put, thus
>> causing a memory leak. Hence add an of_node_put before the return.
>> Issue found with Coccinelle.
>>
>> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
>> ---
>>   drivers/mfd/max77620.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
> 
> Ah, I've just seen that you didn't send this to the list.
> 
> When submitting patches upstream, you must CC at least one list.
> 
> Usually people CC LKML as a matter of course.

My mistake, sorry. I'll CC the list from next time.

Thanking you,
Nishka
> 
> I've CC'ed LMKL here and applied the patch.
> 
>> diff --git a/drivers/mfd/max77620.c b/drivers/mfd/max77620.c
>> index 0c28965fcc6a..a851ff473a44 100644
>> --- a/drivers/mfd/max77620.c
>> +++ b/drivers/mfd/max77620.c
>> @@ -416,8 +416,10 @@ static int max77620_initialise_fps(struct max77620_chip *chip)
>>   
>>   	for_each_child_of_node(fps_np, fps_child) {
>>   		ret = max77620_config_fps(chip, fps_child);
>> -		if (ret < 0)
>> +		if (ret < 0) {
>> +			of_node_put(fps_child);
>>   			return ret;
>> +		}
>>   	}
>>   
>>   	config = chip->enable_global_lpm ? MAX77620_ONOFFCNFG2_SLP_LPM_MSK : 0;
> 


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

end of thread, other threads:[~2019-07-26  8:13 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20190709173132.13886-1-nishkadg.linux@gmail.com>
2019-07-25 12:15 ` [PATCH] mfd: max77620: Add of_node_put() before return Lee Jones
2019-07-26  8:13   ` Nishka Dasgupta

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).