提交 ff7a1790 编写于 作者: M Michael Walle 提交者: Bartosz Golaszewski

gpiolib: Fix irq_domain resource tracking for gpiochip_irqchip_add_domain()

Up until commit 6a45b0e2 ("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: 6a45b0e2 ("gpiolib: Introduce gpiochip_irqchip_add_domain()")
Reported-by: NJiawen Wu <jiawenwu@trustnetic.com>
Signed-off-by: NMichael Walle <mwalle@kernel.org>
Reviewed-by: NLinus Walleij <linus.walleij@linaro.org>
Reviewed-by: NAndy Shevchenko <andy@kernel.org>
Signed-off-by: NBartosz Golaszewski <bartosz.golaszewski@linaro.org>
上级 c1bcb976
......@@ -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
......
......@@ -251,6 +251,14 @@ struct gpio_irq_chip {
*/
bool initialized;
/**
* @domain_is_allocated_externally:
*
* True it the irq_domain was allocated outside of gpiolib, in which
* case gpiolib won't free the irq_domain itself.
*/
bool domain_is_allocated_externally;
/**
* @init_hw: optional routine to initialize hardware before
* an IRQ chip will be added. This is quite useful when
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册