Skip to content

Commit

Permalink
leds: tlc591xx: add missing of_node_put
Browse files Browse the repository at this point in the history
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 <[email protected]>
Acked-by: Pavel Machek <[email protected]>
Signed-off-by: Jacek Anaszewski <[email protected]>
  • Loading branch information
JuliaLawall authored and jacek-anaszewski committed Jul 16, 2017
1 parent 1055790 commit c687291
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions drivers/leds/leds-tlc591xx.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,11 +230,15 @@ 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 ||
priv->leds[reg].active)
priv->leds[reg].active) {
of_node_put(child);
return -EINVAL;
}
priv->leds[reg].active = true;
priv->leds[reg].ldev.name =
of_get_property(child, "label", NULL) ? : child->name;
Expand Down

0 comments on commit c687291

Please sign in to comment.