linuxppc-dev.lists.ozlabs.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: Tang Yuantian, devicetree-discuss, linuxppc-dev, linux-kernel,
	rob.herring

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: devicetree-discuss, linuxppc-dev, linux-kernel, rob.herring

SGkgR3JhbnQubGlrZWx5LA0KDQpJIHJlYWxseSBwcmVjaWF0ZSBpZiB5b3UgY2FuIHNwZW5kIHNv
bWUgdGltZXMgdG8gcmV2aWV3IHRoaXMgcGF0Y2guDQoNClRoYW5rcywNCll1YW50aWFuDQoNCj4g
LS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogVGFuZyBZdWFudGlhbi1CMjk5ODMN
Cj4gU2VudDogMjAxM8TqNNTCMTDI1SAxMTozNw0KPiBUbzogZ3JhbnQubGlrZWx5QHNlY3JldGxh
Yi5jYQ0KPiBDYzogcm9iLmhlcnJpbmdAY2FseGVkYS5jb207IGRldmljZXRyZWUtZGlzY3Vzc0Bs
aXN0cy5vemxhYnMub3JnOyBsaW51eC0NCj4ga2VybmVsQHZnZXIua2VybmVsLm9yZzsgbGludXhw
cGMtZGV2QGxpc3RzLm96bGFicy5vcmc7IFRhbmcgWXVhbnRpYW4tDQo+IEIyOTk4MzsgVGFuZyBZ
dWFudGlhbi1CMjk5ODMNCj4gU3ViamVjdDogW1BBVENIIHYyXSBvZi9iYXNlOiByZWxlYXNlIHRo
ZSBub2RlIGNvcnJlY3RseSBpbg0KPiBvZl9wYXJzZV9waGFuZGxlX3dpdGhfYXJncygpDQo+IA0K
PiBGcm9tOiBUYW5nIFl1YW50aWFuIDx5dWFudGlhbi50YW5nQGZyZWVzY2FsZS5jb20+DQo+IA0K
PiBDYWxsIG9mX25vZGVfcHV0KCkgb25seSB3aGVuIHRoZSBvdXRfYXJncyBpcyBOVUxMIG9uIHN1
Y2Nlc3MsIG9yIHRoZQ0KPiBub2RlJ3MgcmVmZXJlbmNlIGNvdW50IHdpbGwgbm90IG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pbnQgaTsNCj4gIAkJCQlpZiAoV0FSTl9PTihjb3Vu
dCA+IE1BWF9QSEFORExFX0FSR1MpKSBAQCAtDQo+IDExNjYsMTEgKzExNjcsMTAgQEAgc3RhdGlj
IGludCBfX29mX3BhcnNlX3BoYW5kbGVfd2l0aF9hcmdzKGNvbnN0IHN0cnVjdA0KPiBkZXZpY2Vf
bm9kZSAqbnAsDQo+ICAJCQkJb3V0X2FyZ3MtPmFyZ3NfY291bnQgPSBjb3VudDsNCj4gIAkJCQlm
b3IgKGkgPSAwOyBpIDwgY291bnQ7IGkrKykNCj4gIAkJCQkJb3V0X2FyZ3MtPmFyZ3NbaV0gPSBi
ZTMyX3RvX2NwdXAobGlzdCsrKTsNCj4gKwkJCX0gZWxzZSBpZiAobm9kZSkgew0KPiArCQkJCW9m
X25vZGVfcHV0KG5vZGUpOw0KPiAgCQkJfQ0KPiANCj4gLQkJCS8qIEZvdW5kIGl0ISByZXR1cm4g
c3VjY2VzcyAqLw0KPiAtCQkJaWYgKG5vZGUpDQo+IC0JCQkJb2Zfbm9kZV9wdXQobm9kZSk7DQo+
ICAJCQlyZXR1cm4gMDsNCj4gIAkJfQ0KPiANCj4gLS0NCj4gMS44LjANCg0K

^ 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: 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: devicetree-discuss, linuxppc-dev, lkml, Rob Herring

PiAtLS0tLU9yaWdpbmFsIE1lc3NhZ2UtLS0tLQ0KPiBGcm9tOiBUaW11ciBUYWJpIFttYWlsdG86
dGltdXJAdGFiaS5vcmddDQo+IFNlbnQ6IDIwMTPE6jTUwjE2yNUgMTk6MzcNCj4gVG86IFRhbmcg
WXVhbnRpYW4tQjI5OTgzDQo+IENjOiBHcmFudCBMaWtlbHk7IGRldmljZXRyZWUtZGlzY3Vzczsg
bGludXhwcGMtZGV2QGxpc3RzLm96bGFicy5vcmc7IGxrbWw7DQo+IFJvYiBIZXJyaW5nDQo+IFN1
YmplY3Q6IFJlOiBbUEFUQ0ggdjJdIG9mL2Jhc2U6IHJlbGVhc2UgdGhlIG5vZGUgY29ycmVjdGx5
IGluDQo+IG9mX3BhcnNlX3BoYW5kbGVfd2l0aF9hcmdzKCkNCj4gDQo+IE9uIFR1ZSwgQXByIDks
IDIwMTMgYXQgMTA6MzYgUE0sICA8WXVhbnRpYW4uVGFuZ0BmcmVlc2NhbGUuY29tPiB3cm90ZToN
Cj4gPg0KPiA+ICsgICAgICAgICAgICAgICAgICAgICAgIC8qIEZvdW5kIGl0ISByZXR1cm4gc3Vj
Y2VzcyAqLw0KPiANCj4gSSdtIHByZXR0eSBzdXJlIHRoaXMgY29tbWVudCBpcyBpbiB0aGUgd3Jv
bmcgcGxhY2UuDQoNCkl0IGlzIG5vdCBwZXJmZWN0LCBidXQgYWNjZXB0YWJsZS4NCg0KLVl1YW50
aWFuDQoNCg==

^ 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: 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: devicetree-discuss, linuxppc-dev, lkml, Rob Herring

DQoNCj4gLS0tLS1PcmlnaW5hbCBNZXNzYWdlLS0tLS0NCj4gRnJvbTogVGltdXIgVGFiaSBbbWFp
bHRvOnRpbXVyQHRhYmkub3JnXQ0KPiBTZW50OiAyMDEzxOo01MIxN8jVIDExOjMxDQo+IFRvOiBU
YW5nIFl1YW50aWFuLUIyOTk4Mw0KPiBDYzogR3JhbnQgTGlrZWx5OyBkZXZpY2V0cmVlLWRpc2N1
c3M7IGxpbnV4cHBjLWRldkBsaXN0cy5vemxhYnMub3JnOyBsa21sOw0KPiBSb2IgSGVycmluZw0K
PiBTdWJqZWN0OiBSZTogW1BBVENIIHYyXSBvZi9iYXNlOiByZWxlYXNlIHRoZSBub2RlIGNvcnJl
Y3RseSBpbg0KPiBvZl9wYXJzZV9waGFuZGxlX3dpdGhfYXJncygpDQo+IA0KPiBUYW5nIFl1YW50
aWFuLUIyOTk4MyB3cm90ZToNCj4gPj4gPk9uIFR1ZSwgQXByIDksIDIwMTMgYXQgMTA6MzYgUE0s
PFl1YW50aWFuLlRhbmdAZnJlZXNjYWxlLmNvbT4gIHdyb3RlOg0KPiA+Pj4gPiA+DQo+ID4+PiA+
ID4rICAgICAgICAgICAgICAgICAgICAgICAvKiBGb3VuZCBpdCEgcmV0dXJuIHN1Y2Nlc3MgKi8N
Cj4gPj4gPg0KPiA+PiA+SSdtIHByZXR0eSBzdXJlIHRoaXMgY29tbWVudCBpcyBpbiB0aGUgd3Jv
bmcgcGxhY2UuDQo+IA0KPiA+IEl0IGlzIG5vdCBwZXJmZWN0LCBidXQgYWNjZXB0YWJsZS4NCj4g
DQo+IExpa2UgSSBzYWlkLCBJJ20gcHJldHR5IHN1cmUgaXQncyBpbiB0aGUgd3JvbmcgcGxhY2Uu
DQo+IA0KDQpJdCB3YXMgcGxhY2VkIG9uIEVMU0Ugc3RhdGVtZW50IG9yaWdpbmFsbHksIEkgbW92
ZWQgaXQgdG8gSUYgc3RhdGVtZW50Lg0KV2h5IGlzIGl0IHNvIHdyb25nPw0KDQpUaGFua3MsDQpZ
dWFudGlhbg0K

^ 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: 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: devicetree-discuss, linuxppc-dev, linux-kernel, rob.herring

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