summaryrefslogtreecommitdiffstats
path: root/drivers/gpio/gpiolib.c
diff options
context:
space:
mode:
authorGrygorii Strashko2015-06-25 19:30:50 +0200
committerLinus Walleij2015-07-16 13:19:22 +0200
commit5b76e79c772648991e700f004205e9ac861c77c0 (patch)
tree9cea395249c47dc8c1ab15abdb753da07dbf422d /drivers/gpio/gpiolib.c
parentgpio: pcf857x: get rid of slock spinlock (diff)
downloadkernel-qcow2-linux-5b76e79c772648991e700f004205e9ac861c77c0.tar.gz
kernel-qcow2-linux-5b76e79c772648991e700f004205e9ac861c77c0.tar.xz
kernel-qcow2-linux-5b76e79c772648991e700f004205e9ac861c77c0.zip
gpiolib: irqchip: prevent driver unloading if gpio is used as irq only
Now nothing prevents GPIO driver from being unloaded if its gpios were requested as GPIO IRQs only (without calling gpio_request()). Hence, add calls of try_module_get()/module_put() into gpiochip_irq_reqres/relres() to track such scenario properly. Cc: Johan Hovold <johan@kernel.org> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com> Reviewed-by: Alexandre Courbot <acourbot@nvidia.com> Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
Diffstat (limited to 'drivers/gpio/gpiolib.c')
-rw-r--r--drivers/gpio/gpiolib.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index b1b08b3fa626..debd7c56187d 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -522,10 +522,14 @@ static int gpiochip_irq_reqres(struct irq_data *d)
{
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
+ if (!try_module_get(chip->owner))
+ return -ENODEV;
+
if (gpiochip_lock_as_irq(chip, d->hwirq)) {
chip_err(chip,
"unable to lock HW IRQ %lu for IRQ\n",
d->hwirq);
+ module_put(chip->owner);
return -EINVAL;
}
return 0;
@@ -536,6 +540,7 @@ static void gpiochip_irq_relres(struct irq_data *d)
struct gpio_chip *chip = irq_data_get_irq_chip_data(d);
gpiochip_unlock_as_irq(chip, d->hwirq);
+ module_put(chip->owner);
}
static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset)