Linux LED subsystem development
 help / color / mirror / Atom feed
From: Pavel Machek <pavel@ucw.cz>
To: Julia Lawall <Julia.Lawall@lip6.fr>
Cc: Richard Purdie <rpurdie@rpsys.net>,
	kernel-janitors@vger.kernel.org,
	Jacek Anaszewski <jacek.anaszewski@gmail.com>,
	linux-leds@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] leds: tlc591xx: add missing of_node_put
Date: Sat, 15 Jul 2017 11:02:23 +0200	[thread overview]
Message-ID: <20170715090223.GA21365@amd> (raw)
In-Reply-To: <1500104933-25286-1-git-send-email-Julia.Lawall@lip6.fr>

[-- Attachment #1: Type: text/plain, Size: 1411 bytes --]

On Sat 2017-07-15 09:48:53, Julia Lawall wrote:
> for_each_child_of_node performs an of_node_get on each iteration, so a
> return from the loop requires an of_node_put.
> 
> The semantic patch that fixes this problem is as follows
> (http://coccinelle.lip6.fr):
> 
> // <smpl>
> @@
> local idexpression n;
> expression e,e1;
> iterator name for_each_child_of_node;
> @@
> 
>  for_each_child_of_node(e1,n) {
>    ...
> (
>    of_node_put(n);
> |
>    e = n
> |
>    return n;
> |
> +  of_node_put(n);
> ?  return ...;
> )
>    ...
>  }
> // </smpl>
> 
> Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr>

Acked-by: Pavel Machek <pavel@ucw.cz>

> @@ -230,12 +230,18 @@ tlc591xx_probe(struct i2c_client *client
>  
>  	for_each_child_of_node(np, child) {
>  		err = of_property_read_u32(child, "reg", &reg);
> -		if (err)
> +		if (err) {
> +			of_node_put(child);
>  			return err;
> -		if (reg < 0 || reg >= tlc591xx->max_leds)
> +		}
> +		if (reg < 0 || reg >= tlc591xx->max_leds) {
> +			of_node_put(child);
>  			return -EINVAL;
> -		if (priv->leds[reg].active)
> +		}
> +		if (priv->leds[reg].active) {
> +			of_node_put(child);
>  			return -EINVAL;
> +		}

I'd combine last two if()s into one...
									Pavel
-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 181 bytes --]

  reply	other threads:[~2017-07-15  9:02 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-15  7:48 [PATCH] leds: tlc591xx: add missing of_node_put Julia Lawall
2017-07-15  9:02 ` Pavel Machek [this message]
2017-07-15  9:09   ` Julia Lawall

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=20170715090223.GA21365@amd \
    --to=pavel@ucw.cz \
    --cc=Julia.Lawall@lip6.fr \
    --cc=jacek.anaszewski@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-leds@vger.kernel.org \
    --cc=rpurdie@rpsys.net \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox