[PATCH 04/10] gpio: rockchip: Unregister gpiochip on pin-range lookup errors

Lee Jones lee at kernel.org
Thu Dec 3 12:55:02 PST 2026


After gpiochip_add_data() succeeds in rockchip_gpiolib_register(), the
fallback path when gpio-ranges is absent returns -ENODATA or -ENODEV
directly when the parent pinctrl node or device cannot be found,
skipping the fail label that calls gpiochip_remove().

Jump to the fail label on both error paths so the GPIO chip is properly
unregistered on probe failure.

Fixes: 936ee2675eee ("gpio/rockchip: add driver for rockchip gpio")
Closes: https://sashiko.dev/#/bug/linux-d336bb33-7381-45ac-868f-1124190c27a1
Cc: stable at vger.kernel.org
Signed-off-by: Lee Jones <lee at kernel.org>
---
 drivers/gpio/gpio-rockchip.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpio-rockchip.c b/drivers/gpio/gpio-rockchip.c
index 714604c11d78..a620c98718de 100644
--- a/drivers/gpio/gpio-rockchip.c
+++ b/drivers/gpio/gpio-rockchip.c
@@ -613,13 +613,17 @@ static int rockchip_gpiolib_register(struct rockchip_pin_bank *bank)
 		struct device_node *pctlnp = of_get_parent(bank->of_node);
 		struct pinctrl_dev *pctldev = NULL;
 
-		if (!pctlnp)
-			return -ENODATA;
+		if (!pctlnp) {
+			ret = -ENODATA;
+			goto fail;
+		}
 
 		pctldev = of_pinctrl_get(pctlnp);
 		of_node_put(pctlnp);
-		if (!pctldev)
-			return -ENODEV;
+		if (!pctldev) {
+			ret = -ENODEV;
+			goto fail;
+		}
 
 		ret = gpiochip_add_pin_range(gc, dev_name(pctldev->dev), 0,
 					     bank->pin_base, bank->nr_pins);
-- 
2.56.1.911.g883d8bcb20-goog




More information about the linux-arm-kernel mailing list