linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gpio: fix gpio leak in gpiochip_add error path
@ 2015-05-04 15:23 Johan Hovold
  2015-05-12  7:00 ` Alexandre Courbot
  2015-05-12  8:57 ` Linus Walleij
  0 siblings, 2 replies; 3+ messages in thread
From: Johan Hovold @ 2015-05-04 15:23 UTC (permalink / raw)
  To: Linus Walleij; +Cc: Alexandre Courbot, linux-gpio, linux-kernel, Johan Hovold

Make sure to free any hogged gpios on errors in gpiochip_add.

Also move all forward declarations to the top of the file.

Fixes: f625d4601759 ("gpio: add GPIO hogging mechanism")
Signed-off-by: Johan Hovold <johan@kernel.org>
---

Here's another fix for 4.1.

Johan


 drivers/gpio/gpiolib.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 2ce3df3504e6..3b0b063ceb76 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -53,6 +53,11 @@ static DEFINE_MUTEX(gpio_lookup_lock);
 static LIST_HEAD(gpio_lookup_list);
 LIST_HEAD(gpio_chips);
 
+
+static void gpiochip_free_hogs(struct gpio_chip *chip);
+static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip);
+
+
 static inline void desc_set_label(struct gpio_desc *d, const char *label)
 {
 	d->label = label;
@@ -297,6 +302,7 @@ int gpiochip_add(struct gpio_chip *chip)
 
 err_remove_chip:
 	acpi_gpiochip_remove(chip);
+	gpiochip_free_hogs(chip);
 	of_gpiochip_remove(chip);
 	spin_lock_irqsave(&gpio_lock, flags);
 	list_del(&chip->list);
@@ -313,10 +319,6 @@ err_free_descs:
 }
 EXPORT_SYMBOL_GPL(gpiochip_add);
 
-/* Forward-declaration */
-static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip);
-static void gpiochip_free_hogs(struct gpio_chip *chip);
-
 /**
  * gpiochip_remove() - unregister a gpio_chip
  * @chip: the chip to unregister
-- 
2.0.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: fix gpio leak in gpiochip_add error path
  2015-05-04 15:23 [PATCH] gpio: fix gpio leak in gpiochip_add error path Johan Hovold
@ 2015-05-12  7:00 ` Alexandre Courbot
  2015-05-12  8:57 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Alexandre Courbot @ 2015-05-12  7:00 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Linus Walleij, linux-gpio@vger.kernel.org,
	Linux Kernel Mailing List

On Tue, May 5, 2015 at 12:23 AM, Johan Hovold <johan@kernel.org> wrote:
> Make sure to free any hogged gpios on errors in gpiochip_add.
>
> Also move all forward declarations to the top of the file.
>
> Fixes: f625d4601759 ("gpio: add GPIO hogging mechanism")
> Signed-off-by: Johan Hovold <johan@kernel.org>

Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] gpio: fix gpio leak in gpiochip_add error path
  2015-05-04 15:23 [PATCH] gpio: fix gpio leak in gpiochip_add error path Johan Hovold
  2015-05-12  7:00 ` Alexandre Courbot
@ 2015-05-12  8:57 ` Linus Walleij
  1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2015-05-12  8:57 UTC (permalink / raw)
  To: Johan Hovold
  Cc: Alexandre Courbot, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org

On Mon, May 4, 2015 at 5:23 PM, Johan Hovold <johan@kernel.org> wrote:

> Make sure to free any hogged gpios on errors in gpiochip_add.
>
> Also move all forward declarations to the top of the file.
>
> Fixes: f625d4601759 ("gpio: add GPIO hogging mechanism")
> Signed-off-by: Johan Hovold <johan@kernel.org>

Applied for fixes.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2015-05-12  8:57 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-04 15:23 [PATCH] gpio: fix gpio leak in gpiochip_add error path Johan Hovold
2015-05-12  7:00 ` Alexandre Courbot
2015-05-12  8:57 ` Linus Walleij

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).