Skip to content

Commit

Permalink
gpio: fix memory leak and sleep-while-atomic
Browse files Browse the repository at this point in the history
Fix memory leak and sleep-while-atomic in gpiochip_remove.

The memory leak was introduced by afa82fa ("gpio / ACPI: Move event
handling registration to gpiolib irqchip helpers") that moved the
release of acpi interrupt resources to gpiochip_irqchip_remove, but by
then the resources are no longer accessible as the acpi_gpio_chip has
already been freed by acpi_gpiochip_remove.

Note that this also fixes a few potential sleep-while-atomics, which has
been around since 1425052 ("gpio: add IRQ chip helpers in gpiolib")
when the call to gpiochip_irqchip_remove while holding a spinlock was
added (a couple of irq-domain paths can end up grabbing mutexes).

Fixes: afa82fa ("gpio / ACPI: Move event handling registration to
gpiolib irqchip helpers")
Fixes: 1425052 ("gpio: add IRQ chip helpers in gpiolib")
Cc: stable <stable@vger.kernel.org>

Signed-off-by: Johan Hovold <johan@kernel.org>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
  • Loading branch information
Johan Hovold authored and Linus Walleij committed Jan 14, 2015
1 parent 05aa520 commit 00acc3d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/gpio/gpiolib.c
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,12 @@ void gpiochip_remove(struct gpio_chip *chip)
unsigned long flags;
unsigned id;

gpiochip_irqchip_remove(chip);

acpi_gpiochip_remove(chip);

spin_lock_irqsave(&gpio_lock, flags);

gpiochip_irqchip_remove(chip);
gpiochip_remove_pin_ranges(chip);
of_gpiochip_remove(chip);

Expand Down

0 comments on commit 00acc3d

Please sign in to comment.