[PATCH 2/2] gpio: fix cleanup path on hog failure
From: Bartosz Golaszewski
Date: Tue Jun 09 2026 - 08:25:17 EST
If gpiochip_hog_lines() successfully processes some hogs but fails on
a later one, the error handling path in gpiochip_add_data_with_key()
jumps directly to err_remove_of_chip. This leaks resources allocated
earlier for ACPI, interrupts and hogs that were successfully processed.
Use the right label in error path.
Closes: https://sashiko.dev/#/patchset/20260608210108.36248-1-dan%40reactivated.net
Fixes: d1d564ec4992 ("gpio: move hogs into GPIO core")
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxxxxxxxx>
---
drivers/gpio/gpiolib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 1fc7ee9e1158d21f7c75e6cb95c33f0af44835c8..0cd79906d95c60035db1f6adc49bcfcfd3cc751b 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1316,7 +1316,7 @@ int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
ret = gpiochip_hog_lines(gc);
if (ret)
- goto err_remove_of_chip;
+ goto err_free_hogs;
ret = gpiochip_irqchip_init_valid_mask(gc);
if (ret)
--
2.47.3