summaryrefslogtreecommitdiffstats
path: root/drivers/leds/leds-tlc591xx.c
diff options
context:
space:
mode:
authorJulia Lawall <Julia.Lawall@lip6.fr>2017-07-15 11:58:19 +0200
committerJacek Anaszewski <jacek.anaszewski@gmail.com>2017-07-16 18:45:43 +0200
commitc68729119f4d2993bec3c9cb999ad76de5aeddba (patch)
treeb1713aa8c04b372cce31504f707bf7565647b41f /drivers/leds/leds-tlc591xx.c
parentleds: tlc591xx: merge conditional tests (diff)
downloadlinux-c68729119f4d2993bec3c9cb999ad76de5aeddba.tar.xz
linux-c68729119f4d2993bec3c9cb999ad76de5aeddba.zip
leds: tlc591xx: add missing of_node_put
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> Signed-off-by: Jacek Anaszewski <jacek.anaszewski@gmail.com>
Diffstat (limited to 'drivers/leds/leds-tlc591xx.c')
-rw-r--r--drivers/leds/leds-tlc591xx.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/drivers/leds/leds-tlc591xx.c b/drivers/leds/leds-tlc591xx.c
index fcc87ee82453..f5357f6d9e58 100644
--- a/drivers/leds/leds-tlc591xx.c
+++ b/drivers/leds/leds-tlc591xx.c
@@ -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;