[v1,1/1] gpiolib: Fix the error path order in gpiochip_add_data_with_key()

Message ID 20240221192846.4156888-1-andriy.shevchenko@linux.intel.com
State New
Headers
Series [v1,1/1] gpiolib: Fix the error path order in gpiochip_add_data_with_key() |

Commit Message

Andy Shevchenko Feb. 21, 2024, 7:28 p.m. UTC
  After shuffling the code, error path wasn't updated correctly.
Fix it here.

Fixes: ba5c5effe02c ("gpio: initialize descriptor SRCU structure before adding OF-based chips")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/gpio/gpiolib.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
  

Comments

Andy Shevchenko Feb. 29, 2024, 6:21 p.m. UTC | #1
On Thu, Feb 29, 2024 at 06:26:29PM +0100, Bartosz Golaszewski wrote:
> On Thu, Feb 29, 2024 at 5:29 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> >
> > > > I'm sorry I really need more (morning) coffee, maybe you can simply update
> > > > yourself or submit a correct fix?
> > >
> > > Ok, I'll apply this and send a fix on top of it.
> >
> > I don't see any progress with this. Do I need to do something?
> 
> No, it just fell through the cracks. I applied this now and sent my
> own fix on top.

Thank you!
  

Patch

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 4b4812bbcafd..1706edb3ee3f 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1056,6 +1056,7 @@  int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
 	gpiochip_irqchip_free_valid_mask(gc);
 err_remove_acpi_chip:
 	acpi_gpiochip_remove(gc);
+	gpiochip_remove_pin_ranges(gc);
 err_remove_of_chip:
 	gpiochip_free_hogs(gc);
 	of_gpiochip_remove(gc);
@@ -1063,7 +1064,6 @@  int gpiochip_add_data_with_key(struct gpio_chip *gc, void *data,
 	for (i = 0; i < gdev->ngpio; i++)
 		cleanup_srcu_struct(&gdev->descs[i].srcu);
 err_free_gpiochip_mask:
-	gpiochip_remove_pin_ranges(gc);
 	gpiochip_free_valid_mask(gc);
 err_cleanup_gdev_srcu:
 	cleanup_srcu_struct(&gdev->srcu);