]> git.baikalelectronics.ru Git - kernel.git/commit
gpio: of: Fix of_gpiochip_add() error path
authorGeert Uytterhoeven <geert+renesas@glider.be>
Thu, 28 Mar 2019 13:13:47 +0000 (14:13 +0100)
committerLinus Walleij <linus.walleij@linaro.org>
Thu, 28 Mar 2019 16:58:34 +0000 (17:58 +0100)
commitcc0df4e7429adfe03ae044a50566699248e98175
tree707a89a002434ede152561da9bb2a3344afce331
parent9a51152202079de921223ddbc09c3e2bf1aed032
gpio: of: Fix of_gpiochip_add() error path

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: 7ae15b4763969d81 ("gpio: of: Return error if gpio hog configuration failed")
Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
Reviewed-by: Mukesh Ojha <mojha@codeaurora.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
drivers/gpio/gpiolib-of.c