linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH -next] gpio: of: add missing of_node_put() in of_gpiochip_scan_gpios()
@ 2016-10-29 16:13 Wei Yongjun
  2016-10-29 18:14 ` Vladimir Zapolskiy
  2016-10-31  8:23 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Wei Yongjun @ 2016-10-29 16:13 UTC (permalink / raw)
  To: Linus Walleij, Alexandre Courbot; +Cc: Wei Yongjun, linux-gpio

From: Wei Yongjun <weiyongjun1@huawei.com>

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>
---
 drivers/gpio/gpiolib-of.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index b46be18..92b185f 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -251,8 +251,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;


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-10-31  8:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-29 16:13 [PATCH -next] gpio: of: add missing of_node_put() in of_gpiochip_scan_gpios() Wei Yongjun
2016-10-29 18:14 ` Vladimir Zapolskiy
2016-10-31  8:23 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).