Skip to contentSkip to conversation

gpiolib: gpio_request_one(): add missing gpio_free()

PATCH In review Aaro Koskinen 2 participants 3 messages Dec 9, 2010 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpiolib: gpio_request_one(): add missing gpio_free()

If GPIO request succeeds, but configuration fails, it should be released.

---
 drivers/gpio/gpiolib.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/gpio/gpiolib.c +3 -0
index 21da9c1..649550e 100644
@@ -1281,6 +1281,9 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
 		err = gpio_direction_output(gpio,
 				(flags & GPIOF_INIT_HIGH) ? 1 : 0);
 
+	if (err)
+		gpio_free(gpio);
+
 	return err;
 }
 EXPORT_SYMBOL_GPL(gpio_request_one);
Signature · 1 line
1.5.6.5
Acked-by on v1 1/1
#1 lore raw
Quoted 3 lines · Aaro Koskinen

If GPIO request succeeds, but configuration fails, it should be released.

Quoted 22 lines

---
 drivers/gpio/gpiolib.c |    3 +++

 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/gpio/gpiolib.c +3 -1
index 21da9c1..649550e 100644
@@ -1281,6 +1281,9 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
                err = gpio_direction_output(gpio,
                                (flags & GPIOF_INIT_HIGH) ? 1 : 0);
 
+       if (err)
+               gpio_free(gpio);
+
        return err;
  }
  EXPORT_SYMBOL_GPL(gpio_request_one);
--

1.5.6.5

Acked-by on v1 1/1
#2 lore raw
In reply to Aaro Koskinen
Quoted 3 lines · Aaro Koskinen

If GPIO request succeeds, but configuration fails, it should be released.

Quoted 22 lines

---
 drivers/gpio/gpiolib.c |    3 +++

 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/gpio/gpiolib.c +3 -1
index 21da9c1..649550e 100644
@@ -1281,6 +1281,9 @@ int gpio_request_one(unsigned gpio, unsigned long flags, const char *label)
                err = gpio_direction_output(gpio,
                                (flags & GPIOF_INIT_HIGH) ? 1 : 0);
 
+       if (err)
+               gpio_free(gpio);
+
        return err;
  }
  EXPORT_SYMBOL_GPL(gpio_request_one);
--

1.5.6.5