Linux GPIO subsystem development
 help / color / mirror / Atom feed
From: Sergio Paracuellos <sergio.paracuellos@gmail.com>
To: linux-gpio@vger.kernel.org
Cc: linusw@kernel.org, brgl@kernel.org, vicencb@gmail.com,
	linux-kernel@vger.kernel.org, stable@vger.kernel.org,
	Sashiko <sashiko-bot@kernel.org>
Subject: [PATCH v2 3/4] gpio: mt7621: be sure IRQ domain is created before exposing GPIO chips
Date: Fri, 26 Jun 2026 08:01:11 +0200	[thread overview]
Message-ID: <20260626060112.2498324-4-sergio.paracuellos@gmail.com> (raw)
In-Reply-To: <20260626060112.2498324-1-sergio.paracuellos@gmail.com>

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>
---
 drivers/gpio/gpio-mt7621.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpio/gpio-mt7621.c b/drivers/gpio/gpio-mt7621.c
index 57384ef74703..1b0b5247d3c9 100644
--- a/drivers/gpio/gpio-mt7621.c
+++ b/drivers/gpio/gpio-mt7621.c
@@ -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;
 }
 
-- 
2.43.0


  parent reply	other threads:[~2026-06-26  6:01 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26  6:01 [PATCH v2 0/4] gpio: mt7621: address Sashiko complains and other cleanups Sergio Paracuellos
2026-06-26  6:01 ` [PATCH v2 1/4] gpio: mt7621: avoid corruption of shared interrupt trigger state Sergio Paracuellos
2026-06-26  6:01 ` [PATCH v2 2/4] gpio: mt7621: more robust management of IRQ domain teardown Sergio Paracuellos
2026-06-26  6:01 ` Sergio Paracuellos [this message]
2026-06-30 14:06   ` [PATCH v2 3/4] gpio: mt7621: be sure IRQ domain is created before exposing GPIO chips Bartosz Golaszewski
2026-06-30 14:12     ` Sergio Paracuellos
2026-06-26  6:01 ` [PATCH v2 4/4] gpio: mt7621: unify naming style in driver code Sergio Paracuellos
2026-06-30 14:37 ` (subset) [PATCH v2 0/4] gpio: mt7621: address Sashiko complains and other cleanups Bartosz Golaszewski
2026-06-30 17:33   ` Sergio Paracuellos
2026-07-01  7:04     ` Bartosz Golaszewski
2026-07-01  7:13       ` Sergio Paracuellos
2026-07-06  8:47 ` Bartosz Golaszewski
2026-07-06 12:22   ` Sergio Paracuellos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260626060112.2498324-4-sergio.paracuellos@gmail.com \
    --to=sergio.paracuellos@gmail.com \
    --cc=brgl@kernel.org \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=sashiko-bot@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=vicencb@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox