Skip to content

Commit

Permalink
gpio: of: add missing of_node_put() in of_gpiochip_scan_gpios()
Browse files Browse the repository at this point in the history
When terminating for_each_available_child_of_node() iteration
with break or return, of_node_put() should be used to prevent
stale device node references from being left behind.

This is detected by Coccinelle semantic patch.

Signed-off-by: Wei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: Vladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Wei Yongjun authored and Linus Walleij committed Oct 31, 2016
1 parent 550a953 commit 09e258a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/gpio/gpiolib-of.c
Original file line number Diff line number Diff line change
Expand Up @@ -247,8 +247,10 @@ static int of_gpiochip_scan_gpios(struct gpio_chip *chip)
continue;

ret = gpiod_hog(desc, name, lflags, dflags);
if (ret < 0)
if (ret < 0) {
of_node_put(np);
return ret;
}
}

return 0;
Expand Down

0 comments on commit 09e258a

Please sign in to comment.