All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>
To: Amitoj Kaur Chawla <amitoj1606-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
Cc: pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	julia.lawall-L2FTfq7BK8M@public.gmane.org
Subject: Re: [PATCH] of: resolver: Add missing of_node_put
Date: Wed, 27 Jan 2016 16:05:31 +0000	[thread overview]
Message-ID: <20160127160531.GB17123@leverpostej> (raw)
In-Reply-To: <20160127152017.GA16048@amitoj-Inspiron-3542>

On Wed, Jan 27, 2016 at 08:50:17PM +0530, Amitoj Kaur Chawla wrote:
> for_each_child_of_node performs an of_node_get on each iteration, so
> to break out of the loop an of_node_put is required.
> 
> Found using Coccinelle. The semantic patch used for this is as follows:
> 
> // <smpl>
> @@
> expression e;
> local idexpression n;
> @@
> 
>  for_each_child_of_node(..., n) {
>    ... when != of_node_put(n)
>        when != e = n
> (
>    return n;
> |
> +  of_node_put(n);
> ?  return ...;
> )
>    ...
>  }
> // </smpl
> 
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
> ---
>  drivers/of/resolver.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
> index 640eb4c..e2a0143 100644
> --- a/drivers/of/resolver.c
> +++ b/drivers/of/resolver.c
> @@ -40,8 +40,10 @@ static struct device_node *__of_find_node_by_full_name(struct device_node *node,
>  
>  	for_each_child_of_node(node, child) {
>  		found = __of_find_node_by_full_name(child, full_name);
> -		if (found != NULL)
> +		if (found != NULL) {
> +			of_node_put(child);
>  			return found;
> +		}
>  	}
>  
>  	return NULL;

I don't think this is quite right. When child == found, this change will
leave it decremented.

Thanks,
Mark.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

WARNING: multiple messages have this Message-ID (diff)
From: Mark Rutland <mark.rutland@arm.com>
To: Amitoj Kaur Chawla <amitoj1606@gmail.com>
Cc: pantelis.antoniou@konsulko.com, robh+dt@kernel.org,
	frowand.list@gmail.com, grant.likely@linaro.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	julia.lawall@lip6.fr
Subject: Re: [PATCH] of: resolver: Add missing of_node_put
Date: Wed, 27 Jan 2016 16:05:31 +0000	[thread overview]
Message-ID: <20160127160531.GB17123@leverpostej> (raw)
In-Reply-To: <20160127152017.GA16048@amitoj-Inspiron-3542>

On Wed, Jan 27, 2016 at 08:50:17PM +0530, Amitoj Kaur Chawla wrote:
> for_each_child_of_node performs an of_node_get on each iteration, so
> to break out of the loop an of_node_put is required.
> 
> Found using Coccinelle. The semantic patch used for this is as follows:
> 
> // <smpl>
> @@
> expression e;
> local idexpression n;
> @@
> 
>  for_each_child_of_node(..., n) {
>    ... when != of_node_put(n)
>        when != e = n
> (
>    return n;
> |
> +  of_node_put(n);
> ?  return ...;
> )
>    ...
>  }
> // </smpl
> 
> Signed-off-by: Amitoj Kaur Chawla <amitoj1606@gmail.com>
> ---
>  drivers/of/resolver.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/of/resolver.c b/drivers/of/resolver.c
> index 640eb4c..e2a0143 100644
> --- a/drivers/of/resolver.c
> +++ b/drivers/of/resolver.c
> @@ -40,8 +40,10 @@ static struct device_node *__of_find_node_by_full_name(struct device_node *node,
>  
>  	for_each_child_of_node(node, child) {
>  		found = __of_find_node_by_full_name(child, full_name);
> -		if (found != NULL)
> +		if (found != NULL) {
> +			of_node_put(child);
>  			return found;
> +		}
>  	}
>  
>  	return NULL;

I don't think this is quite right. When child == found, this change will
leave it decremented.

Thanks,
Mark.

  reply	other threads:[~2016-01-27 16:05 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-27 15:20 [PATCH] of: resolver: Add missing of_node_put Amitoj Kaur Chawla
2016-01-27 15:20 ` Amitoj Kaur Chawla
2016-01-27 16:05 ` Mark Rutland [this message]
2016-01-27 16:05   ` Mark Rutland
2016-01-27 16:14   ` Pantelis Antoniou
     [not found]     ` <FE79FA58-A084-47BE-B872-7D57AC2B4D75-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-01-27 16:21       ` Mark Rutland
2016-01-27 16:21         ` Mark Rutland
2016-01-27 18:02         ` Pantelis Antoniou
2016-01-27 19:48           ` Julia Lawall
2016-01-28 11:28             ` Mark Rutland
2016-01-28 11:36               ` Julia Lawall
2016-01-28 11:36                 ` Julia Lawall
     [not found]           ` <FF19B941-89E4-4954-9818-E352FE9A0E97-OWPKS81ov/FWk0Htik3J/w@public.gmane.org>
2016-01-27 22:32             ` Julia Lawall
2016-01-27 22:32               ` Julia Lawall
2016-01-29 16:45     ` Rob Herring
2016-01-29 17:33       ` Pantelis Antoniou
2016-01-29 17:33         ` Pantelis Antoniou
2016-01-29 23:46         ` Frank Rowand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160127160531.GB17123@leverpostej \
    --to=mark.rutland-5wv7dgnigg8@public.gmane.org \
    --cc=amitoj1606-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=frowand.list-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org \
    --cc=grant.likely-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
    --cc=julia.lawall-L2FTfq7BK8M@public.gmane.org \
    --cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=pantelis.antoniou-OWPKS81ov/FWk0Htik3J/w@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.