linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args()
@ 2013-04-10  3:36 Yuantian.Tang
  2013-04-16  6:54 ` Tang Yuantian-B29983
  2013-04-16 11:37 ` Timur Tabi
  0 siblings, 2 replies; 10+ messages in thread
From: Yuantian.Tang @ 2013-04-10  3:36 UTC (permalink / raw)
  To: grant.likely
  Cc: rob.herring, devicetree-discuss, linux-kernel, linuxppc-dev,
	Tang Yuantian, Tang Yuantian

From: Tang Yuantian <yuantian.tang@freescale.com>

Call of_node_put() only when the out_args is NULL on success,
or the node's reference count will not be correct because the caller
will call of_node_put() again.

Signed-off-by: Tang Yuantian <Yuantian.Tang@freescale.com>
---
v2:
	- modified the title and description. the 1st patch title is:
	  of: remove the unnecessary of_node_put for of_parse_phandle_with_args()
	  the 1st patch is not good enough.

 drivers/of/base.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/of/base.c b/drivers/of/base.c
index 321d3ef..ee94f64 100644
--- a/drivers/of/base.c
+++ b/drivers/of/base.c
@@ -1158,6 +1158,7 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
 			if (!phandle)
 				goto err;
 
+			/* Found it! return success */
 			if (out_args) {
 				int i;
 				if (WARN_ON(count > MAX_PHANDLE_ARGS))
@@ -1166,11 +1167,10 @@ static int __of_parse_phandle_with_args(const struct device_node *np,
 				out_args->args_count = count;
 				for (i = 0; i < count; i++)
 					out_args->args[i] = be32_to_cpup(list++);
+			} else if (node) {
+				of_node_put(node);
 			}
 
-			/* Found it! return success */
-			if (node)
-				of_node_put(node);
 			return 0;
 		}
 
-- 
1.8.0



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

* RE: [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args()
  2013-04-10  3:36 [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args() Yuantian.Tang
@ 2013-04-16  6:54 ` Tang Yuantian-B29983
  2013-04-17 14:57   ` Grant Likely
  2013-04-16 11:37 ` Timur Tabi
  1 sibling, 1 reply; 10+ messages in thread
From: Tang Yuantian-B29983 @ 2013-04-16  6:54 UTC (permalink / raw)
  To: Tang Yuantian-B29983, grant.likely
  Cc: rob.herring, devicetree-discuss, linux-kernel, linuxppc-dev

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 2021 bytes --]

Hi Grant.likely,

I really preciate if you can spend some times to review this patch.

Thanks,
Yuantian

> -----Original Message-----
> From: Tang Yuantian-B29983
> Sent: 2013Äê4ÔÂ10ÈÕ 11:37
> To: grant.likely@secretlab.ca
> Cc: rob.herring@calxeda.com; devicetree-discuss@lists.ozlabs.org; linux-
> kernel@vger.kernel.org; linuxppc-dev@lists.ozlabs.org; Tang Yuantian-
> B29983; Tang Yuantian-B29983
> Subject: [PATCH v2] of/base: release the node correctly in
> of_parse_phandle_with_args()
> 
> From: Tang Yuantian <yuantian.tang@freescale.com>
> 
> Call of_node_put() only when the out_args is NULL on success, or the
> node's reference count will not be correct because the caller will call
> of_node_put() again.
> 
> Signed-off-by: Tang Yuantian <Yuantian.Tang@freescale.com>
> ---
> v2:
> 	- modified the title and description. the 1st patch title is:
> 	  of: remove the unnecessary of_node_put for
> of_parse_phandle_with_args()
> 	  the 1st patch is not good enough.
> 
>  drivers/of/base.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/of/base.c b/drivers/of/base.c index 321d3ef..ee94f64
> 100644
> --- a/drivers/of/base.c
> +++ b/drivers/of/base.c
> @@ -1158,6 +1158,7 @@ static int __of_parse_phandle_with_args(const
> struct device_node *np,
>  			if (!phandle)
>  				goto err;
> 
> +			/* Found it! return success */
>  			if (out_args) {
>  				int i;
>  				if (WARN_ON(count > MAX_PHANDLE_ARGS)) @@ -
> 1166,11 +1167,10 @@ static int __of_parse_phandle_with_args(const struct
> device_node *np,
>  				out_args->args_count = count;
>  				for (i = 0; i < count; i++)
>  					out_args->args[i] = be32_to_cpup(list++);
> +			} else if (node) {
> +				of_node_put(node);
>  			}
> 
> -			/* Found it! return success */
> -			if (node)
> -				of_node_put(node);
>  			return 0;
>  		}
> 
> --
> 1.8.0

ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args()
  2013-04-10  3:36 [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args() Yuantian.Tang
  2013-04-16  6:54 ` Tang Yuantian-B29983
@ 2013-04-16 11:37 ` Timur Tabi
  2013-04-17  2:44   ` Tang Yuantian-B29983
  1 sibling, 1 reply; 10+ messages in thread
From: Timur Tabi @ 2013-04-16 11:37 UTC (permalink / raw)
  To: Yuantian.Tang
  Cc: Grant Likely, devicetree-discuss, linuxppc-dev, lkml, Rob Herring

On Tue, Apr 9, 2013 at 10:36 PM,  <Yuantian.Tang@freescale.com> wrote:
>
> +                       /* Found it! return success */

I'm pretty sure this comment is in the wrong place.

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

* RE: [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args()
  2013-04-16 11:37 ` Timur Tabi
@ 2013-04-17  2:44   ` Tang Yuantian-B29983
  2013-04-17  3:30     ` Timur Tabi
  0 siblings, 1 reply; 10+ messages in thread
From: Tang Yuantian-B29983 @ 2013-04-17  2:44 UTC (permalink / raw)
  To: Timur Tabi
  Cc: Grant Likely, devicetree-discuss, linuxppc-dev, lkml, Rob Herring

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 718 bytes --]

> -----Original Message-----
> From: Timur Tabi [mailto:timur@tabi.org]
> Sent: 2013Äê4ÔÂ16ÈÕ 19:37
> To: Tang Yuantian-B29983
> Cc: Grant Likely; devicetree-discuss; linuxppc-dev@lists.ozlabs.org; lkml;
> Rob Herring
> Subject: Re: [PATCH v2] of/base: release the node correctly in
> of_parse_phandle_with_args()
> 
> On Tue, Apr 9, 2013 at 10:36 PM,  <Yuantian.Tang@freescale.com> wrote:
> >
> > +                       /* Found it! return success */
> 
> I'm pretty sure this comment is in the wrong place.

It is not perfect, but acceptable.

-Yuantian

ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args()
  2013-04-17  2:44   ` Tang Yuantian-B29983
@ 2013-04-17  3:30     ` Timur Tabi
  2013-04-17  4:49       ` Tang Yuantian-B29983
  0 siblings, 1 reply; 10+ messages in thread
From: Timur Tabi @ 2013-04-17  3:30 UTC (permalink / raw)
  To: Tang Yuantian-B29983
  Cc: Grant Likely, devicetree-discuss, linuxppc-dev, lkml, Rob Herring

Tang Yuantian-B29983 wrote:
>> >On Tue, Apr 9, 2013 at 10:36 PM,<Yuantian.Tang@freescale.com>  wrote:
>>> > >
>>> > >+                       /* Found it! return success */
>> >
>> >I'm pretty sure this comment is in the wrong place.

> It is not perfect, but acceptable.

Like I said, I'm pretty sure it's in the wrong place.

-- 
Timur Tabi

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

* RE: [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args()
  2013-04-17  3:30     ` Timur Tabi
@ 2013-04-17  4:49       ` Tang Yuantian-B29983
  2013-04-17 11:27         ` Timur Tabi
  0 siblings, 1 reply; 10+ messages in thread
From: Tang Yuantian-B29983 @ 2013-04-17  4:49 UTC (permalink / raw)
  To: Timur Tabi
  Cc: Grant Likely, devicetree-discuss, linuxppc-dev, lkml, Rob Herring

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="gb2312", Size: 939 bytes --]



> -----Original Message-----
> From: Timur Tabi [mailto:timur@tabi.org]
> Sent: 2013Äê4ÔÂ17ÈÕ 11:31
> To: Tang Yuantian-B29983
> Cc: Grant Likely; devicetree-discuss; linuxppc-dev@lists.ozlabs.org; lkml;
> Rob Herring
> Subject: Re: [PATCH v2] of/base: release the node correctly in
> of_parse_phandle_with_args()
> 
> Tang Yuantian-B29983 wrote:
> >> >On Tue, Apr 9, 2013 at 10:36 PM,<Yuantian.Tang@freescale.com>  wrote:
> >>> > >
> >>> > >+                       /* Found it! return success */
> >> >
> >> >I'm pretty sure this comment is in the wrong place.
> 
> > It is not perfect, but acceptable.
> 
> Like I said, I'm pretty sure it's in the wrong place.
> 

It was placed on ELSE statement originally, I moved it to IF statement.
Why is it so wrong?

Thanks,
Yuantian
ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

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

* Re: [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args()
  2013-04-17  4:49       ` Tang Yuantian-B29983
@ 2013-04-17 11:27         ` Timur Tabi
  0 siblings, 0 replies; 10+ messages in thread
From: Timur Tabi @ 2013-04-17 11:27 UTC (permalink / raw)
  To: Tang Yuantian-B29983
  Cc: Grant Likely, devicetree-discuss, linuxppc-dev, lkml, Rob Herring

Tang Yuantian-B29983 wrote:
> It was placed on ELSE statement originally, I moved it to IF statement.
> Why is it so wrong?

Because the logic of the comment applies to the else-condition, not the 
if-condtion.

-- 
Timur Tabi

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

* RE: [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args()
  2013-04-16  6:54 ` Tang Yuantian-B29983
@ 2013-04-17 14:57   ` Grant Likely
  2013-04-17 21:52     ` Timur Tabi
  0 siblings, 1 reply; 10+ messages in thread
From: Grant Likely @ 2013-04-17 14:57 UTC (permalink / raw)
  To: Tang Yuantian-B29983, Tang Yuantian-B29983
  Cc: rob.herring, devicetree-discuss, linux-kernel, linuxppc-dev

On Tue, 16 Apr 2013 06:54:40 +0000, Tang Yuantian-B29983 <B29983@freescale.com> wrote:
> Hi Grant.likely,
> 
> I really preciate if you can spend some times to review this patch.

Applied, thanks.

g.

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

* Re: [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args()
  2013-04-17 14:57   ` Grant Likely
@ 2013-04-17 21:52     ` Timur Tabi
  2013-04-17 22:00       ` Grant Likely
  0 siblings, 1 reply; 10+ messages in thread
From: Timur Tabi @ 2013-04-17 21:52 UTC (permalink / raw)
  To: Grant Likely
  Cc: Tang Yuantian-B29983, devicetree-discuss, linuxppc-dev,
	linux-kernel, rob.herring

On Wed, Apr 17, 2013 at 9:57 AM, Grant Likely <grant.likely@secretlab.ca> wrote:
>
>> I really preciate if you can spend some times to review this patch.
>
> Applied, thanks.

Pff.  Why do I bother?

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

* Re: [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args()
  2013-04-17 21:52     ` Timur Tabi
@ 2013-04-17 22:00       ` Grant Likely
  0 siblings, 0 replies; 10+ messages in thread
From: Grant Likely @ 2013-04-17 22:00 UTC (permalink / raw)
  To: Timur Tabi
  Cc: Tang Yuantian-B29983, devicetree-discuss, linuxppc-dev,
	linux-kernel, rob.herring

On Wed, Apr 17, 2013 at 10:52 PM, Timur Tabi <timur@tabi.org> wrote:
> On Wed, Apr 17, 2013 at 9:57 AM, Grant Likely <grant.likely@secretlab.ca> wrote:
>>
>>> I really preciate if you can spend some times to review this patch.
>>
>> Applied, thanks.
>
> Pff.  Why do I bother?

Relax Timur:

http://git.secretlab.ca/?p=linux.git;a=commitdiff;h=b855f16b05a697ac1863adabe99bfba56e6d3199

g.



--
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

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

end of thread, other threads:[~2013-04-17 22:00 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-04-10  3:36 [PATCH v2] of/base: release the node correctly in of_parse_phandle_with_args() Yuantian.Tang
2013-04-16  6:54 ` Tang Yuantian-B29983
2013-04-17 14:57   ` Grant Likely
2013-04-17 21:52     ` Timur Tabi
2013-04-17 22:00       ` Grant Likely
2013-04-16 11:37 ` Timur Tabi
2013-04-17  2:44   ` Tang Yuantian-B29983
2013-04-17  3:30     ` Timur Tabi
2013-04-17  4:49       ` Tang Yuantian-B29983
2013-04-17 11:27         ` Timur Tabi

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).