diff mbox

[RESEND,2/4] gpu: drm: omapdrm: dss-of: add missing of_node_put after calling of_parse_phandle

Message ID 1468552625-23546-3-git-send-email-peter.chen@nxp.com (mailing list archive)
State New, archived
Headers show

Commit Message

Peter Chen July 15, 2016, 3:17 a.m. UTC
of_node_put needs to be called when the device node which is got
from of_parse_phandle has finished using.

Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
Signed-off-by: Peter Chen <peter.chen@nxp.com>
---
 drivers/gpu/drm/omapdrm/dss/dss-of.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Tomi Valkeinen Aug. 11, 2016, 9:21 a.m. UTC | #1
Hi,

On 15/07/16 06:17, Peter Chen wrote:
> of_node_put needs to be called when the device node which is got
> from of_parse_phandle has finished using.
> 
> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> Signed-off-by: Peter Chen <peter.chen@nxp.com>
> ---
>  drivers/gpu/drm/omapdrm/dss/dss-of.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c b/drivers/gpu/drm/omapdrm/dss/dss-of.c
> index dfd4e96..e256d87 100644
> --- a/drivers/gpu/drm/omapdrm/dss/dss-of.c
> +++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c
> @@ -125,15 +125,16 @@ u32 dss_of_port_get_port_number(struct device_node *port)
>  
>  static struct device_node *omapdss_of_get_remote_port(const struct device_node *node)
>  {
> -	struct device_node *np;
> +	struct device_node *np, *np_parent;
>  
>  	np = of_parse_phandle(node, "remote-endpoint", 0);
>  	if (!np)
>  		return NULL;
>  
> -	np = of_get_next_parent(np);
> +	np_parent = of_get_next_parent(np);
> +	of_node_put(np);
>  
> -	return np;
> +	return np_parent;
>  }

The doc for of_get_next_parent() says:

"This is like of_get_parent() except that it drops the
refcount on the passed node, making it suitable for iterating".

So this patch breaks omapdrm.

 Tomi
Peter Chen Aug. 11, 2016, 9:44 a.m. UTC | #2
>On 15/07/16 06:17, Peter Chen wrote:

>> of_node_put needs to be called when the device node which is got from

>> of_parse_phandle has finished using.

>>

>> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>

>> Signed-off-by: Peter Chen <peter.chen@nxp.com>

>> ---

>>  drivers/gpu/drm/omapdrm/dss/dss-of.c | 7 ++++---

>>  1 file changed, 4 insertions(+), 3 deletions(-)

>>

>> diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c

>> b/drivers/gpu/drm/omapdrm/dss/dss-of.c

>> index dfd4e96..e256d87 100644

>> --- a/drivers/gpu/drm/omapdrm/dss/dss-of.c

>> +++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c

>> @@ -125,15 +125,16 @@ u32 dss_of_port_get_port_number(struct

>> device_node *port)

>>

>>  static struct device_node *omapdss_of_get_remote_port(const struct

>> device_node *node)  {

>> -	struct device_node *np;

>> +	struct device_node *np, *np_parent;

>>

>>  	np = of_parse_phandle(node, "remote-endpoint", 0);

>>  	if (!np)

>>  		return NULL;

>>

>> -	np = of_get_next_parent(np);

>> +	np_parent = of_get_next_parent(np);

>> +	of_node_put(np);

>>

>> -	return np;

>> +	return np_parent;

>>  }

>

>The doc for of_get_next_parent() says:

>

>"This is like of_get_parent() except that it drops the refcount on the passed node,

>making it suitable for iterating".

>


It is my careless, thanks for pointing it.

Peter
Daniel Vetter Aug. 11, 2016, 10:50 a.m. UTC | #3
On Thu, Aug 11, 2016 at 09:44:55AM +0000, Peter Chen wrote:
> 
>  
> >On 15/07/16 06:17, Peter Chen wrote:
> >> of_node_put needs to be called when the device node which is got from
> >> of_parse_phandle has finished using.
> >>
> >> Cc: Tomi Valkeinen <tomi.valkeinen@ti.com>
> >> Signed-off-by: Peter Chen <peter.chen@nxp.com>
> >> ---
> >>  drivers/gpu/drm/omapdrm/dss/dss-of.c | 7 ++++---
> >>  1 file changed, 4 insertions(+), 3 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c
> >> b/drivers/gpu/drm/omapdrm/dss/dss-of.c
> >> index dfd4e96..e256d87 100644
> >> --- a/drivers/gpu/drm/omapdrm/dss/dss-of.c
> >> +++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c
> >> @@ -125,15 +125,16 @@ u32 dss_of_port_get_port_number(struct
> >> device_node *port)
> >>
> >>  static struct device_node *omapdss_of_get_remote_port(const struct
> >> device_node *node)  {
> >> -	struct device_node *np;
> >> +	struct device_node *np, *np_parent;
> >>
> >>  	np = of_parse_phandle(node, "remote-endpoint", 0);
> >>  	if (!np)
> >>  		return NULL;
> >>
> >> -	np = of_get_next_parent(np);
> >> +	np_parent = of_get_next_parent(np);
> >> +	of_node_put(np);
> >>
> >> -	return np;
> >> +	return np_parent;
> >>  }
> >
> >The doc for of_get_next_parent() says:
> >
> >"This is like of_get_parent() except that it drops the refcount on the passed node,
> >making it suitable for iterating".
> >
> 
> It is my careless, thanks for pointing it.

Since it's already replied, should we just revert, or is a fixup patch
better?
-Daniel
diff mbox

Patch

diff --git a/drivers/gpu/drm/omapdrm/dss/dss-of.c b/drivers/gpu/drm/omapdrm/dss/dss-of.c
index dfd4e96..e256d87 100644
--- a/drivers/gpu/drm/omapdrm/dss/dss-of.c
+++ b/drivers/gpu/drm/omapdrm/dss/dss-of.c
@@ -125,15 +125,16 @@  u32 dss_of_port_get_port_number(struct device_node *port)
 
 static struct device_node *omapdss_of_get_remote_port(const struct device_node *node)
 {
-	struct device_node *np;
+	struct device_node *np, *np_parent;
 
 	np = of_parse_phandle(node, "remote-endpoint", 0);
 	if (!np)
 		return NULL;
 
-	np = of_get_next_parent(np);
+	np_parent = of_get_next_parent(np);
+	of_node_put(np);
 
-	return np;
+	return np_parent;
 }
 
 struct device_node *