2010-12-09 12:57:43

by Aaro Koskinen

[permalink] [raw]
Subject: [PATCH] gpiolib: gpio_request_one(): add missing gpio_free()

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

Signed-off-by: Aaro Koskinen <[email protected]>
---
drivers/gpio/gpiolib.c | 3 +++
1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 21da9c1..649550e 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -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


2010-12-09 13:15:55

by Eric Miao

[permalink] [raw]
Subject: Re: [PATCH] gpiolib: gpio_request_one(): add missing gpio_free()

On Thu, Dec 9, 2010 at 8:58 PM, Aaro Koskinen <[email protected]> wrote:
> If GPIO request succeeds, but configuration fails, it should be released.
>
> Signed-off-by: Aaro Koskinen <[email protected]>

Acked-by: Eric Miao <[email protected]>

> ---
>  drivers/gpio/gpiolib.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 21da9c1..649550e 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -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
>
>

2010-12-09 13:16:21

by Eric Miao

[permalink] [raw]
Subject: Re: [PATCH] gpiolib: gpio_request_one(): add missing gpio_free()

On Thu, Dec 9, 2010 at 8:58 PM, Aaro Koskinen <[email protected]> wrote:
> If GPIO request succeeds, but configuration fails, it should be released.
>
> Signed-off-by: Aaro Koskinen <[email protected]>

Acked-by: Eric Miao <[email protected]>

> ---
>  drivers/gpio/gpiolib.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index 21da9c1..649550e 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -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
>
>