All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] i2c: busses: i2c-fsi.c: Add of_put_node() before break
@ 2019-07-06 13:19 Nishka Dasgupta
  2019-09-03 18:15 ` Wolfram Sang
  2019-09-03 18:33 ` Wolfram Sang
  0 siblings, 2 replies; 4+ messages in thread
From: Nishka Dasgupta @ 2019-07-06 13:19 UTC (permalink / raw)
  To: eajames, linux-i2c, openbmc; +Cc: Nishka Dasgupta

Each iteration of for_each_available_childe_of_node puts the previous
node, but in the case of a break from the middle of the loop, there
is no put, thus causing a memory leak. Add an of_node_put before the
break.
Issue found with Coccinelle.

Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
---
 drivers/i2c/busses/i2c-fsi.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c
index 1e2be2219a60..5e01875082c3 100644
--- a/drivers/i2c/busses/i2c-fsi.c
+++ b/drivers/i2c/busses/i2c-fsi.c
@@ -685,8 +685,10 @@ static int fsi_i2c_probe(struct device *dev)
 			continue;
 
 		port = kzalloc(sizeof(*port), GFP_KERNEL);
-		if (!port)
+		if (!port) {
+			of_node_put(np);
 			break;
+		}
 
 		port->master = i2c;
 		port->port = port_no;
-- 
2.19.1

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

* Re: [PATCH] i2c: busses: i2c-fsi.c: Add of_put_node() before break
  2019-07-06 13:19 [PATCH] i2c: busses: i2c-fsi.c: Add of_put_node() before break Nishka Dasgupta
@ 2019-09-03 18:15 ` Wolfram Sang
  2019-09-03 18:18   ` Eddie James
  2019-09-03 18:33 ` Wolfram Sang
  1 sibling, 1 reply; 4+ messages in thread
From: Wolfram Sang @ 2019-09-03 18:15 UTC (permalink / raw)
  To: Nishka Dasgupta; +Cc: eajames, linux-i2c, openbmc

[-- Attachment #1: Type: text/plain, Size: 1033 bytes --]

On Sat, Jul 06, 2019 at 06:49:11PM +0530, Nishka Dasgupta wrote:
> Each iteration of for_each_available_childe_of_node puts the previous
> node, but in the case of a break from the middle of the loop, there
> is no put, thus causing a memory leak. Add an of_node_put before the
> break.
> Issue found with Coccinelle.
> 
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
> ---

Eddie, are you okay with this change?

>  drivers/i2c/busses/i2c-fsi.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c
> index 1e2be2219a60..5e01875082c3 100644
> --- a/drivers/i2c/busses/i2c-fsi.c
> +++ b/drivers/i2c/busses/i2c-fsi.c
> @@ -685,8 +685,10 @@ static int fsi_i2c_probe(struct device *dev)
>  			continue;
>  
>  		port = kzalloc(sizeof(*port), GFP_KERNEL);
> -		if (!port)
> +		if (!port) {
> +			of_node_put(np);
>  			break;
> +		}
>  
>  		port->master = i2c;
>  		port->port = port_no;
> -- 
> 2.19.1
> 

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] i2c: busses: i2c-fsi.c: Add of_put_node() before break
  2019-09-03 18:15 ` Wolfram Sang
@ 2019-09-03 18:18   ` Eddie James
  0 siblings, 0 replies; 4+ messages in thread
From: Eddie James @ 2019-09-03 18:18 UTC (permalink / raw)
  To: Wolfram Sang, Nishka Dasgupta; +Cc: eajames, linux-i2c, openbmc


On 9/3/19 1:15 PM, Wolfram Sang wrote:
> On Sat, Jul 06, 2019 at 06:49:11PM +0530, Nishka Dasgupta wrote:
>> Each iteration of for_each_available_childe_of_node puts the previous
>> node, but in the case of a break from the middle of the loop, there
>> is no put, thus causing a memory leak. Add an of_node_put before the
>> break.
>> Issue found with Coccinelle.
>>
>> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>
>> ---
> Eddie, are you okay with this change?


Yes, sorry must have missed this when it first came in.

Thanks.


Reviewed-by: Eddie James <eajames@linux.ibm.com>


>
>>   drivers/i2c/busses/i2c-fsi.c | 4 +++-
>>   1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/i2c/busses/i2c-fsi.c b/drivers/i2c/busses/i2c-fsi.c
>> index 1e2be2219a60..5e01875082c3 100644
>> --- a/drivers/i2c/busses/i2c-fsi.c
>> +++ b/drivers/i2c/busses/i2c-fsi.c
>> @@ -685,8 +685,10 @@ static int fsi_i2c_probe(struct device *dev)
>>   			continue;
>>   
>>   		port = kzalloc(sizeof(*port), GFP_KERNEL);
>> -		if (!port)
>> +		if (!port) {
>> +			of_node_put(np);
>>   			break;
>> +		}
>>   
>>   		port->master = i2c;
>>   		port->port = port_no;
>> -- 
>> 2.19.1
>>

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

* Re: [PATCH] i2c: busses: i2c-fsi.c: Add of_put_node() before break
  2019-07-06 13:19 [PATCH] i2c: busses: i2c-fsi.c: Add of_put_node() before break Nishka Dasgupta
  2019-09-03 18:15 ` Wolfram Sang
@ 2019-09-03 18:33 ` Wolfram Sang
  1 sibling, 0 replies; 4+ messages in thread
From: Wolfram Sang @ 2019-09-03 18:33 UTC (permalink / raw)
  To: Nishka Dasgupta; +Cc: eajames, linux-i2c, openbmc

[-- Attachment #1: Type: text/plain, Size: 423 bytes --]

On Sat, Jul 06, 2019 at 06:49:11PM +0530, Nishka Dasgupta wrote:
> Each iteration of for_each_available_childe_of_node puts the previous
> node, but in the case of a break from the middle of the loop, there
> is no put, thus causing a memory leak. Add an of_node_put before the
> break.
> Issue found with Coccinelle.
> 
> Signed-off-by: Nishka Dasgupta <nishkadg.linux@gmail.com>

Applied to for-next, thanks!


[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2019-09-03 23:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-06 13:19 [PATCH] i2c: busses: i2c-fsi.c: Add of_put_node() before break Nishka Dasgupta
2019-09-03 18:15 ` Wolfram Sang
2019-09-03 18:18   ` Eddie James
2019-09-03 18:33 ` Wolfram Sang

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.