diff mbox

[1/2] gpiolib: irqchip: use irq_find_mapping while removing irqchip

Message ID 1411661364-19620-1-git-send-email-grygorii.strashko@ti.com
State Not Applicable, archived
Headers show

Commit Message

Grygorii Strashko Sept. 25, 2014, 4:09 p.m. UTC
There is no guarantee that VIRQs will be allocated sequentially
for gpio irqchip in gpiochip_irqchip_add().
Therefore, it's unsafe to dispose VIRQ in gpiochip_irqchip_remove()
basing on index relatively to stored irq_base value.

Hence, use irq_find_mapping for VIRQ finding  in gpiochip_irqchip_remove()
instead of irq_base + index.

Reported-by: Wang, Yalin <Yalin.Wang@sonymobile.com>
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
---
 drivers/gpio/gpiolib.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Linus Walleij Sept. 26, 2014, 8:40 a.m. UTC | #1
On Thu, Sep 25, 2014 at 6:09 PM, Grygorii Strashko
<grygorii.strashko@ti.com> wrote:

> There is no guarantee that VIRQs will be allocated sequentially
> for gpio irqchip in gpiochip_irqchip_add().
> Therefore, it's unsafe to dispose VIRQ in gpiochip_irqchip_remove()
> basing on index relatively to stored irq_base value.
>
> Hence, use irq_find_mapping for VIRQ finding  in gpiochip_irqchip_remove()
> instead of irq_base + index.
>
> Reported-by: Wang, Yalin <Yalin.Wang@sonymobile.com>
> Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>

Patch applied.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 15cc0bb..f6bf368 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -524,7 +524,8 @@  static void gpiochip_irqchip_remove(struct gpio_chip *gpiochip)
 	/* Remove all IRQ mappings and delete the domain */
 	if (gpiochip->irqdomain) {
 		for (offset = 0; offset < gpiochip->ngpio; offset++)
-			irq_dispose_mapping(gpiochip->irq_base + offset);
+			irq_dispose_mapping(
+				irq_find_mapping(gpiochip->irqdomain, offset));
 		irq_domain_remove(gpiochip->irqdomain);
 	}