Patch "gpiolib: Fix irq_domain resource tracking for gpiochip_irqchip_add_domain()" has been added to the 6.3-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    gpiolib: Fix irq_domain resource tracking for gpiochip_irqchip_add_domain()

to the 6.3-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     gpiolib-fix-irq_domain-resource-tracking-for-gpiochi.patch
and it can be found in the queue-6.3 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 2e36626e2c45ebb599b000fb08254ddb8cfc60ac
Author: Michael Walle <mwalle@xxxxxxxxxx>
Date:   Mon Jun 19 10:56:07 2023 +0200

    gpiolib: Fix irq_domain resource tracking for gpiochip_irqchip_add_domain()
    
    [ Upstream commit ff7a1790fbf92f1bdd0966d3f0da3ea808ede876 ]
    
    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@xxxxxxxxxxxxxx>
    Signed-off-by: Michael Walle <mwalle@xxxxxxxxxx>
    Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
    Reviewed-by: Andy Shevchenko <andy@xxxxxxxxxx>
    Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@xxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 1cfddbb3443d0..ce8f71e06eb62 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -1716,7 +1716,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++) {
@@ -1762,6 +1762,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
diff --git a/include/linux/gpio/driver.h b/include/linux/gpio/driver.h
index ccd8a512d8546..b769ff6b00fdd 100644
--- a/include/linux/gpio/driver.h
+++ b/include/linux/gpio/driver.h
@@ -244,6 +244,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



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux