]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
gpio: mt7621: be sure IRQ domain is created before exposing GPIO chips
authorSergio Paracuellos <sergio.paracuellos@gmail.com>
Fri, 26 Jun 2026 06:01:11 +0000 (08:01 +0200)
committerBartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
Tue, 30 Jun 2026 14:36:35 +0000 (16:36 +0200)
Function 'mediatek_gpio_bank_probe()' registers three GPIO chips using
'devm_gpiochip_add_data()'. At this point, the chips become live and visible
to consumers. However, the IRQ domain isn't allocated and set up until
'mt7621_gpio_irq_setup()' is called after the GPIO chips setup finishes.
If a consumer requests a GPIO IRQ concurrently 'mt7621_gpio_to_irq()' can
be called and pass a NULL irq domain pointer irq_create_mapping(), that can
corrupt the mappings or cause a crash. Fix this possible problem seting up
irq domain before GPIO chips setup is performed.

Cc: stable@vger.kernel.org
Reported-by: Sashiko <sashiko-bot@kernel.org>
Fixes: a46f2e5720f5 ("gpio: mt7621: fix interrupt banks mapping on gpio chips")
Signed-off-by: Sergio Paracuellos <sergio.paracuellos@gmail.com>
Link: https://patch.msgid.link/20260626060112.2498324-4-sergio.paracuellos@gmail.com
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@oss.qualcomm.com>
drivers/gpio/gpio-mt7621.c

index 57384ef74703902e66bd1f5a2597513fe4f95a48..1b0b5247d3c9a3942701b78092751a3ed24bd506 100644 (file)
@@ -466,12 +466,6 @@ mediatek_gpio_probe(struct platform_device *pdev)
        mtk->num_gpios = MTK_BANK_WIDTH * MTK_BANK_CNT;
        platform_set_drvdata(pdev, mtk);
 
-       for (i = 0; i < MTK_BANK_CNT; i++) {
-               ret = mediatek_gpio_bank_probe(dev, i);
-               if (ret)
-                       return ret;
-       }
-
        if (mtk->gpio_irq > 0) {
                ret = mt7621_gpio_irq_setup(pdev, mtk);
                if (ret)
@@ -482,6 +476,12 @@ mediatek_gpio_probe(struct platform_device *pdev)
        if (ret)
                return ret;
 
+       for (i = 0; i < MTK_BANK_CNT; i++) {
+               ret = mediatek_gpio_bank_probe(dev, i);
+               if (ret)
+                       return ret;
+       }
+
        return 0;
 }