diff options
author | Johan Hovold <johan@kernel.org> | 2015-01-12 11:12:27 -0500 |
---|---|---|
committer | Linus Walleij <linus.walleij@linaro.org> | 2015-01-14 08:25:48 -0500 |
commit | 00acc3dc248063f982cfacfbe5e78c0d6797ffef (patch) | |
tree | c60363d93215f8027e14bee371746ccb5d4431d2 /drivers/gpio/gpiolib.c | |
parent | 05aa52033494a13178fb550660aea87cd8a99cfd (diff) |
gpio: fix memory leak and sleep-while-atomic
Fix memory leak and sleep-while-atomic in gpiochip_remove.
The memory leak was introduced by afa82fab5e13 ("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 1425052097b5 ("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: afa82fab5e13 ("gpio / ACPI: Move event handling registration to
gpiolib irqchip helpers")
Fixes: 1425052097b5 ("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>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r-- | drivers/gpio/gpiolib.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4efb92ca3463..0f8173051edc 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c | |||
@@ -327,11 +327,12 @@ void gpiochip_remove(struct gpio_chip *chip) | |||
327 | unsigned long flags; | 327 | unsigned long flags; |
328 | unsigned id; | 328 | unsigned id; |
329 | 329 | ||
330 | gpiochip_irqchip_remove(chip); | ||
331 | |||
330 | acpi_gpiochip_remove(chip); | 332 | acpi_gpiochip_remove(chip); |
331 | 333 | ||
332 | spin_lock_irqsave(&gpio_lock, flags); | 334 | spin_lock_irqsave(&gpio_lock, flags); |
333 | 335 | ||
334 | gpiochip_irqchip_remove(chip); | ||
335 | gpiochip_remove_pin_ranges(chip); | 336 | gpiochip_remove_pin_ranges(chip); |
336 | of_gpiochip_remove(chip); | 337 | of_gpiochip_remove(chip); |
337 | 338 | ||