From: Vikrant Yadav <vikrantyadav4802@gmail.com>
To: lorenzo@kernel.org, john@phrozen.org, linusw@kernel.org
Cc: angelogioacchino.delregno@collabora.com,
benjamin.larsson@genexis.eu, linux-mediatek@lists.infradead.org,
linux-gpio@vger.kernel.org,
Vikrant Yadav <vikrantyadav4802@gmail.com>
Subject: [PATCH v2] pinctrl: airoha: fix parent IRQ vs gpiochip registration order
Date: Wed, 2 Dec 2026 18:38:45 +0530 [thread overview]
Message-ID: <20261202130845.30868-1-vikrantyadav4802@gmail.com> (raw)
The parent IRQ is requested before devm_gpiochip_add_data(), so the
handler is live while the gpiochip and its IRQ domain do not exist.
On unbind, devm releases resources in reverse order: gpiochip_remove()
runs first and frees the IRQ domain, while the shared parent IRQ is
still registered. gpiolib does not clear gc->irq.domain, so a late
interrupt makes generic_handle_domain_irq() use a stale pointer.
On probe, the handler can run before the gpiochip is added, while
gc->irq.domain is still NULL.
Register the gpiochip first and request the parent IRQ afterwards.
The IRQ is then requested only once the domain exists, and freed
before the domain is removed.
Fixes: 1c8ace2d0725 ("pinctrl: airoha: Add support for EN7581 SoC")
Signed-off-by: Vikrant Yadav <vikrantyadav4802@gmail.com>
Reviewed-by: John Crispin <john@phrozen.org>
---
Changes in v2:
- Fix description: domain pointer is stale (not NULL) after
gpiochip_remove(); NULL case is on probe side (John Crispin)
- Collect Reviewed-by from John Crispin
Link to v1: https://lore.kernel.org/linux-gpio/20261201145624.30092-1-vikrantyadav4802@gmail.com/
drivers/pinctrl/airoha/pinctrl-airoha.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/drivers/pinctrl/airoha/pinctrl-airoha.c b/drivers/pinctrl/airoha/pinctrl-airoha.c
index 32d4af044ae1..4a0d31a6e08c 100644
--- a/drivers/pinctrl/airoha/pinctrl-airoha.c
+++ b/drivers/pinctrl/airoha/pinctrl-airoha.c
@@ -390,12 +390,17 @@ static int airoha_pinctrl_add_gpiochip(struct airoha_pinctrl *pinctrl,
if (irq < 0)
return irq;
- err = devm_request_irq(dev, irq, airoha_irq_handler, IRQF_SHARED,
- dev_name(dev), pinctrl);
+ /*
+ * Register the gpiochip (and thus the IRQ domain) before requesting
+ * the parent IRQ. devm unwinds in reverse order, so free_irq() runs
+ * before gpiochip_remove() and the handler never sees a missing domain.
+ */
+ err = devm_gpiochip_add_data(dev, gc, pinctrl);
if (err)
return err;
- return devm_gpiochip_add_data(dev, gc, pinctrl);
+ return devm_request_irq(dev, irq, airoha_irq_handler, IRQF_SHARED,
+ dev_name(dev), pinctrl);
}
/* pinmux callbacks */
--
2.34.1
reply other threads:[~2026-12-02 13:09 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20261202130845.30868-1-vikrantyadav4802@gmail.com \
--to=vikrantyadav4802@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=benjamin.larsson@genexis.eu \
--cc=john@phrozen.org \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=lorenzo@kernel.org \
/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