From: Wei Yongjun Date: Sat, 29 Oct 2016 16:13:52 +0000 (+0000) Subject: gpio: of: add missing of_node_put() in of_gpiochip_scan_gpios() X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=09e258af4edaa10ee9aa3164923ee07d5863d637;p=linux.git 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 Reviewed-by: Vladimir Zapolskiy Signed-off-by: Linus Walleij --- diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c index 3fa4e84b43271..5236966b1bdfc 100644 --- a/drivers/gpio/gpiolib-of.c +++ b/drivers/gpio/gpiolib-of.c @@ -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;