Commit 09e258af authored by Wei Yongjun's avatar Wei Yongjun Committed by Linus Walleij

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: default avatarWei Yongjun <weiyongjun1@huawei.com>
Reviewed-by: default avatarVladimir Zapolskiy <vladimir_zapolskiy@mentor.com>
Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
parent 550a9532
......@@ -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;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment