2
0
mirror of https://github.com/edk2-porting/linux-next.git synced 2024-12-19 02:34:01 +08:00

gpio: of: add missing of_node_put() in of_gpiochip_scan_gpios()

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>
This commit is contained in:
Wei Yongjun 2016-10-29 16:13:52 +00:00 committed by Linus Walleij
parent 550a9532b8
commit 09e258af4e

View File

@ -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;