summaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichael Walle <mwalle@kernel.org>2023-06-19 10:56:07 +0200
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>2023-06-19 14:57:38 +0200
commitff7a1790fbf92f1bdd0966d3f0da3ea808ede876 (patch)
tree1a5c1167a3a01ff649be70fd7aba0466d18a2a24 /drivers
parentgpio: sifive: add missing check for platform_get_irq (diff)
downloadlinux-ff7a1790fbf92f1bdd0966d3f0da3ea808ede876.tar.xz
linux-ff7a1790fbf92f1bdd0966d3f0da3ea808ede876.zip
gpiolib: Fix irq_domain resource tracking for gpiochip_irqchip_add_domain()
Up until commit 6a45b0e2589f ("gpiolib: Introduce gpiochip_irqchip_add_domain()") all irq_domains were allocated by gpiolib itself and thus gpiolib also takes care of freeing it. With gpiochip_irqchip_add_domain() a user of gpiolib can associate an irq_domain with the gpio_chip. This irq_domain is not managed by gpiolib and therefore must not be freed by gpiolib. Fixes: 6a45b0e2589f ("gpiolib: Introduce gpiochip_irqchip_add_domain()") Reported-by: Jiawen Wu <jiawenwu@trustnetic.com> Signed-off-by: Michael Walle <mwalle@kernel.org> Reviewed-by: Linus Walleij <linus.walleij@linaro.org> Reviewed-by: Andy Shevchenko <andy@kernel.org> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/gpio/gpiolib.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 9ecf93cbd801..5be8ad61523e 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1745,7 +1745,7 @@ static void gpiochip_irqchip_remove(struct gpio_chip *gc)
}
/* Remove all IRQ mappings and delete the domain */
- if (gc->irq.domain) {
+ if (!gc->irq.domain_is_allocated_externally && gc->irq.domain) {
unsigned int irq;
for (offset = 0; offset < gc->ngpio; offset++) {
@@ -1791,6 +1791,7 @@ int gpiochip_irqchip_add_domain(struct gpio_chip *gc,
gc->to_irq = gpiochip_to_irq;
gc->irq.domain = domain;
+ gc->irq.domain_is_allocated_externally = true;
/*
* Using barrier() here to prevent compiler from reordering