提交 a918af5b 编写于 作者: G Geert Uytterhoeven 提交者: Greg Kroah-Hartman

gpio: of: Fix of_gpiochip_add() error path

[ Upstream commit f7299d441a4da8a5088e651ea55023525a793a13 ]

If the call to of_gpiochip_scan_gpios() in of_gpiochip_add() fails, no
error handling is performed.  This lead to the need of callers to call
of_gpiochip_remove() on failure, which causes "BAD of_node_put() on ..."
if the failure happened before the call to of_node_get().

Fix this by adding proper error handling.

Note that calling gpiochip_remove_pin_ranges() multiple times causes no
harm: subsequent calls are a no-op.

Fixes: dfbd379b ("gpio: of: Return error if gpio hog configuration failed")
Signed-off-by: NGeert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: NMukesh Ojha <mojha@codeaurora.org>
Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
Signed-off-by: NSasha Levin (Microsoft) <sashal@kernel.org>
上级 43dba153
...@@ -646,7 +646,13 @@ int of_gpiochip_add(struct gpio_chip *chip) ...@@ -646,7 +646,13 @@ int of_gpiochip_add(struct gpio_chip *chip)
of_node_get(chip->of_node); of_node_get(chip->of_node);
return of_gpiochip_scan_gpios(chip); status = of_gpiochip_scan_gpios(chip);
if (status) {
of_node_put(chip->of_node);
gpiochip_remove_pin_ranges(chip);
}
return status;
} }
void of_gpiochip_remove(struct gpio_chip *chip) void of_gpiochip_remove(struct gpio_chip *chip)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册