Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1316819 > unrolled thread

[PATCH] media: platform: exynos4-is: media-dev: Add missing of_node_put

Started byAmitoj Kaur Chawla <amitoj1606@gmail.com>
First post2016-01-25 16:30 +0100
Last post2016-01-26 10:20 +0100
Articles 6 — 4 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] media: platform: exynos4-is: media-dev: Add missing  of_node_put Amitoj Kaur Chawla <amitoj1606@gmail.com> - 2016-01-25 16:30 +0100
    Re: [PATCH] media: platform: exynos4-is: media-dev: Add missing  of_node_put Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-01-26 01:30 +0100
      Re: [PATCH] media: platform: exynos4-is: media-dev: Add missing  of_node_put Julia Lawall <julia.lawall@lip6.fr> - 2016-01-26 07:30 +0100
        Re: [PATCH] media: platform: exynos4-is: media-dev: Add missing  of_node_put Krzysztof Kozlowski <k.kozlowski@samsung.com> - 2016-01-26 08:00 +0100
          Re: [PATCH] media: platform: exynos4-is: media-dev: Add missing  of_node_put Julia Lawall <julia.lawall@lip6.fr> - 2016-01-26 08:20 +0100
            Re: [PATCH] media: platform: exynos4-is: media-dev: Add missing  of_node_put Mauro Carvalho Chehab <mchehab@osg.samsung.com> - 2016-01-26 10:20 +0100

#1316819 — [PATCH] media: platform: exynos4-is: media-dev: Add missing of_node_put

FromAmitoj Kaur Chawla <amitoj1606@gmail.com>
Date2016-01-25 16:30 +0100
Subject[PATCH] media: platform: exynos4-is: media-dev: Add missing of_node_put
Message-ID<qURfB-5VH-35@gated-at.bofh.it>
for_each_available_child_of_node and for_each_child_of_node perform an
of_node_get on each iteration, so to break out of the loop an of_node_put is
required.

Found using Coccinelle. The simplified version of the semantic patch
that is used for this is as follows:

// <smpl>
@@
local idexpression n;
expression e,r;
@@

 for_each_available_child_of_node(r,n) {
   ...
(
   of_node_put(n);
|
   e = n
|
+  of_node_put(n);
?  break;
)
   ...
 }
... when != n
// </smpl>

Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
---
 drivers/media/platform/exynos4-is/media-dev.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
index 4f5586a..09f6e54 100644
--- a/drivers/media/platform/exynos4-is/media-dev.c
+++ b/drivers/media/platform/exynos4-is/media-dev.c
@@ -430,8 +430,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
 			continue;
 
 		ret = fimc_md_parse_port_node(fmd, port, index);
-		if (ret < 0)
+		if (ret < 0) {
+			of_node_put(node);
 			goto rpm_put;
+		}
 		index++;
 	}
 
@@ -442,8 +444,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
 
 	for_each_child_of_node(ports, node) {
 		ret = fimc_md_parse_port_node(fmd, node, index);
-		if (ret < 0)
+		if (ret < 0) {
+			of_node_put(node);
 			break;
+		}
 		index++;
 	}
 rpm_put:
@@ -651,8 +655,10 @@ static int fimc_md_register_platform_entities(struct fimc_md *fmd,
 			ret = fimc_md_register_platform_entity(fmd, pdev,
 							plat_entity);
 		put_device(&pdev->dev);
-		if (ret < 0)
+		if (ret < 0) {
+			of_node_put(node);
 			break;
+		}
 	}
 
 	return ret;
-- 
1.9.1

[toc] | [next] | [standalone]


#1317426

FromKrzysztof Kozlowski <k.kozlowski@samsung.com>
Date2016-01-26 01:30 +0100
Message-ID<qUZGa-3xa-1@gated-at.bofh.it>
In reply to#1316819
On 26.01.2016 00:21, Amitoj Kaur Chawla wrote:
> for_each_available_child_of_node and for_each_child_of_node perform an
> of_node_get on each iteration, so to break out of the loop an of_node_put is
> required.
> 
> Found using Coccinelle. The simplified version of the semantic patch
> that is used for this is as follows:
> 
> // <smpl>
> @@
> local idexpression n;
> expression e,r;
> @@
> 
>  for_each_available_child_of_node(r,n) {
>    ...
> (
>    of_node_put(n);
> |
>    e = n
> |
> +  of_node_put(n);
> ?  break;
> )
>    ...
>  }
> ... when != n
> // </smpl>

Patch iselft looks correct but why are you pasting coccinelle script
into the message?

The script is already present in Linux kernel:
scripts/coccinelle/iterators/device_node_continue.cocci

This just extends the commit message without any meaningful data so with
removal of coccinelle script above:
Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>

Best regards,
Krzysztof

> 
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
>  drivers/media/platform/exynos4-is/media-dev.c | 12 +++++++++---
>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
> index 4f5586a..09f6e54 100644
> --- a/drivers/media/platform/exynos4-is/media-dev.c
> +++ b/drivers/media/platform/exynos4-is/media-dev.c
> @@ -430,8 +430,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
>  			continue;
>  
>  		ret = fimc_md_parse_port_node(fmd, port, index);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			of_node_put(node);
>  			goto rpm_put;
> +		}
>  		index++;
>  	}
>  
> @@ -442,8 +444,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
>  
>  	for_each_child_of_node(ports, node) {
>  		ret = fimc_md_parse_port_node(fmd, node, index);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			of_node_put(node);
>  			break;
> +		}
>  		index++;
>  	}
>  rpm_put:
> @@ -651,8 +655,10 @@ static int fimc_md_register_platform_entities(struct fimc_md *fmd,
>  			ret = fimc_md_register_platform_entity(fmd, pdev,
>  							plat_entity);
>  		put_device(&pdev->dev);
> -		if (ret < 0)
> +		if (ret < 0) {
> +			of_node_put(node);
>  			break;
> +		}
>  	}
>  
>  	return ret;
> 

[toc] | [prev] | [next] | [standalone]


#1317557

FromJulia Lawall <julia.lawall@lip6.fr>
Date2016-01-26 07:30 +0100
Message-ID<qV5iy-7WO-13@gated-at.bofh.it>
In reply to#1317426

On Tue, 26 Jan 2016, Krzysztof Kozlowski wrote:

> On 26.01.2016 00:21, Amitoj Kaur Chawla wrote:
> > for_each_available_child_of_node and for_each_child_of_node perform an
> > of_node_get on each iteration, so to break out of the loop an of_node_put is
> > required.
> > 
> > Found using Coccinelle. The simplified version of the semantic patch
> > that is used for this is as follows:
> > 
> > // <smpl>
> > @@
> > local idexpression n;
> > expression e,r;
> > @@
> > 
> >  for_each_available_child_of_node(r,n) {
> >    ...
> > (
> >    of_node_put(n);
> > |
> >    e = n
> > |
> > +  of_node_put(n);
> > ?  break;
> > )
> >    ...
> >  }
> > ... when != n
> > // </smpl>
> 
> Patch iselft looks correct but why are you pasting coccinelle script
> into the message?
> 
> The script is already present in Linux kernel:
> scripts/coccinelle/iterators/device_node_continue.cocci

I don't think so.  The continue one takes care of the case where there is 
an extraneous of_node_put before a continue, not a missing one before a 
break.  But OK to drop it if it doesn't seem useful.

julia

> This just extends the commit message without any meaningful data so with
> removal of coccinelle script above:
> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> 
> Best regards,
> Krzysztof
> 
> > 
> > Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> > ---
> >  drivers/media/platform/exynos4-is/media-dev.c | 12 +++++++++---
> >  1 file changed, 9 insertions(+), 3 deletions(-)
> > 
> > diff --git a/drivers/media/platform/exynos4-is/media-dev.c b/drivers/media/platform/exynos4-is/media-dev.c
> > index 4f5586a..09f6e54 100644
> > --- a/drivers/media/platform/exynos4-is/media-dev.c
> > +++ b/drivers/media/platform/exynos4-is/media-dev.c
> > @@ -430,8 +430,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
> >  			continue;
> >  
> >  		ret = fimc_md_parse_port_node(fmd, port, index);
> > -		if (ret < 0)
> > +		if (ret < 0) {
> > +			of_node_put(node);
> >  			goto rpm_put;
> > +		}
> >  		index++;
> >  	}
> >  
> > @@ -442,8 +444,10 @@ static int fimc_md_register_sensor_entities(struct fimc_md *fmd)
> >  
> >  	for_each_child_of_node(ports, node) {
> >  		ret = fimc_md_parse_port_node(fmd, node, index);
> > -		if (ret < 0)
> > +		if (ret < 0) {
> > +			of_node_put(node);
> >  			break;
> > +		}
> >  		index++;
> >  	}
> >  rpm_put:
> > @@ -651,8 +655,10 @@ static int fimc_md_register_platform_entities(struct fimc_md *fmd,
> >  			ret = fimc_md_register_platform_entity(fmd, pdev,
> >  							plat_entity);
> >  		put_device(&pdev->dev);
> > -		if (ret < 0)
> > +		if (ret < 0) {
> > +			of_node_put(node);
> >  			break;
> > +		}
> >  	}
> >  
> >  	return ret;
> > 
> 
> 

[toc] | [prev] | [next] | [standalone]


#1317568

FromKrzysztof Kozlowski <k.kozlowski@samsung.com>
Date2016-01-26 08:00 +0100
Message-ID<qV5LA-8nC-1@gated-at.bofh.it>
In reply to#1317557
On 26.01.2016 15:24, Julia Lawall wrote:
> 
> 
> On Tue, 26 Jan 2016, Krzysztof Kozlowski wrote:
> 
>> On 26.01.2016 00:21, Amitoj Kaur Chawla wrote:
>>> for_each_available_child_of_node and for_each_child_of_node perform an
>>> of_node_get on each iteration, so to break out of the loop an of_node_put is
>>> required.
>>>
>>> Found using Coccinelle. The simplified version of the semantic patch
>>> that is used for this is as follows:
>>>
>>> // <smpl>
>>> @@
>>> local idexpression n;
>>> expression e,r;
>>> @@
>>>
>>>  for_each_available_child_of_node(r,n) {
>>>    ...
>>> (
>>>    of_node_put(n);
>>> |
>>>    e = n
>>> |
>>> +  of_node_put(n);
>>> ?  break;
>>> )
>>>    ...
>>>  }
>>> ... when != n
>>> // </smpl>
>>
>> Patch iselft looks correct but why are you pasting coccinelle script
>> into the message?
>>
>> The script is already present in Linux kernel:
>> scripts/coccinelle/iterators/device_node_continue.cocci
> 
> I don't think so.  The continue one takes care of the case where there is 
> an extraneous of_node_put before a continue, not a missing one before a 
> break.  But OK to drop it if it doesn't seem useful.
> 
> julia

You are right - this is not covered by that cocci patch... but I think
is covered by scripts/coccinelle/iterators/fen.cocci, isn't it?

BR,
Krzysztof

> 
>> This just extends the commit message without any meaningful data so with
>> removal of coccinelle script above:
>> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
>>
>> Best regards,
>> Krzysztof
>>
>>>
>>> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
>>> ---
>>>  drivers/media/platform/exynos4-is/media-dev.c | 12 +++++++++---
>>>  1 file changed, 9 insertions(+), 3 deletions(-)

[toc] | [prev] | [next] | [standalone]


#1317573

FromJulia Lawall <julia.lawall@lip6.fr>
Date2016-01-26 08:20 +0100
Message-ID<qV64W-t8-5@gated-at.bofh.it>
In reply to#1317568

On Tue, 26 Jan 2016, Krzysztof Kozlowski wrote:

> On 26.01.2016 15:24, Julia Lawall wrote:
> > 
> > 
> > On Tue, 26 Jan 2016, Krzysztof Kozlowski wrote:
> > 
> >> On 26.01.2016 00:21, Amitoj Kaur Chawla wrote:
> >>> for_each_available_child_of_node and for_each_child_of_node perform an
> >>> of_node_get on each iteration, so to break out of the loop an of_node_put is
> >>> required.
> >>>
> >>> Found using Coccinelle. The simplified version of the semantic patch
> >>> that is used for this is as follows:
> >>>
> >>> // <smpl>
> >>> @@
> >>> local idexpression n;
> >>> expression e,r;
> >>> @@
> >>>
> >>>  for_each_available_child_of_node(r,n) {
> >>>    ...
> >>> (
> >>>    of_node_put(n);
> >>> |
> >>>    e = n
> >>> |
> >>> +  of_node_put(n);
> >>> ?  break;
> >>> )
> >>>    ...
> >>>  }
> >>> ... when != n
> >>> // </smpl>
> >>
> >> Patch iselft looks correct but why are you pasting coccinelle script
> >> into the message?
> >>
> >> The script is already present in Linux kernel:
> >> scripts/coccinelle/iterators/device_node_continue.cocci
> > 
> > I don't think so.  The continue one takes care of the case where there is 
> > an extraneous of_node_put before a continue, not a missing one before a 
> > break.  But OK to drop it if it doesn't seem useful.
> > 
> > julia
> 
> You are right - this is not covered by that cocci patch... but I think
> is covered by scripts/coccinelle/iterators/fen.cocci, isn't it?

Not quite.  That is for of_node_puts after normal loop completion (not 
sure that this problem comes up any more, but at one point there were a 
number of them). There are indeed a lot of ways in which the management of 
reference counts can go wrong...

Anyway, the rule that Amitoj used seems to be pretty reliable, so I'll try 
to get it into the kernel source tree some day soon.

julia

> 
> BR,
> Krzysztof
> 
> > 
> >> This just extends the commit message without any meaningful data so with
> >> removal of coccinelle script above:
> >> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com>
> >>
> >> Best regards,
> >> Krzysztof
> >>
> >>>
> >>> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> >>> ---
> >>>  drivers/media/platform/exynos4-is/media-dev.c | 12 +++++++++---
> >>>  1 file changed, 9 insertions(+), 3 deletions(-)
> 
> 

[toc] | [prev] | [next] | [standalone]


#1317652

FromMauro Carvalho Chehab <mchehab@osg.samsung.com>
Date2016-01-26 10:20 +0100
Message-ID<qV7X4-1ZG-7@gated-at.bofh.it>
In reply to#1317573
Em Tue, 26 Jan 2016 08:12:15 +0100
Julia Lawall <julia.lawall@lip6.fr> escreveu:

> On Tue, 26 Jan 2016, Krzysztof Kozlowski wrote:
> 
> > On 26.01.2016 15:24, Julia Lawall wrote:  
> > > 
> > > 
> > > On Tue, 26 Jan 2016, Krzysztof Kozlowski wrote:
> > >   
> > >> On 26.01.2016 00:21, Amitoj Kaur Chawla wrote:  
> > >>> for_each_available_child_of_node and for_each_child_of_node perform an
> > >>> of_node_get on each iteration, so to break out of the loop an of_node_put is
> > >>> required.
> > >>>
> > >>> Found using Coccinelle. The simplified version of the semantic patch
> > >>> that is used for this is as follows:
> > >>>
> > >>> // <smpl>
> > >>> @@
> > >>> local idexpression n;
> > >>> expression e,r;
> > >>> @@
> > >>>
> > >>>  for_each_available_child_of_node(r,n) {
> > >>>    ...
> > >>> (
> > >>>    of_node_put(n);
> > >>> |
> > >>>    e = n
> > >>> |
> > >>> +  of_node_put(n);
> > >>> ?  break;
> > >>> )
> > >>>    ...
> > >>>  }
> > >>> ... when != n
> > >>> // </smpl>  
> > >>
> > >> Patch iselft looks correct but why are you pasting coccinelle script
> > >> into the message?
> > >>
> > >> The script is already present in Linux kernel:
> > >> scripts/coccinelle/iterators/device_node_continue.cocci  
> > > 
> > > I don't think so.  The continue one takes care of the case where there is 
> > > an extraneous of_node_put before a continue, not a missing one before a 
> > > break.  But OK to drop it if it doesn't seem useful.
> > > 
> > > julia  
> > 
> > You are right - this is not covered by that cocci patch... but I think
> > is covered by scripts/coccinelle/iterators/fen.cocci, isn't it?  
> 
> Not quite. 

If the script is not part of the Kernel, please keep the script in the
patch, as it could be useful in some future.

Regards,
Mauro

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web