Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

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

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
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -247,9 +247,11 @@ 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;
}