From: Saad Anjum <saadanjum239@gmail.com>
To: Linus Walleij <linusw@kernel.org>, Sean Wang <sean.wang@kernel.org>
Cc: AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
Hao Chang <ot_chhao.chang@mediatek.com>,
Qingliang Li <qingliang.li@mediatek.com>,
linux-gpio@vger.kernel.org, linux-mediatek@lists.infradead.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, Saad Anjum <saadanjum239@gmail.com>
Subject: [PATCH] pinctrl: mediatek: common-v2: Fix of_iomap() error check
Date: Mon, 5 Oct 2026 11:06:41 +0500 [thread overview]
Message-ID: <20261005060641.32674-1-saadanjum239@gmail.com> (raw)
of_iomap() returns NULL on failure, never an error pointer, so the
IS_ERR() check in mtk_build_eint() can never be true. The check was
carried over from the previous devm_platform_ioremap_resource_byname()
call, which does return an error pointer, when the EINT registers were
switched to being mapped with of_iomap() to support multiple bases.
If mapping one of the EINT register ranges fails, for example because
the device tree node lists more "reg-names" than "reg" entries so that
of_address_to_resource() fails, or because ioremap() itself fails, the
NULL pointer is stored in hw->eint->base[] and probing continues.
mtk_eint_do_init() then calls mtk_eint_hw_init(), which writes to
eint->base[i] + regs->dom_en, causing a NULL pointer dereference
instead of a clean probe failure.
Check for NULL and return -ENOMEM instead. The existing error path
already skips NULL entries when unmapping, so any ranges mapped before
the failure are still released.
Fixes: 3ef9f710efcb ("pinctrl: mediatek: Add EINT support for multiple addresses")
Signed-off-by: Saad Anjum <saadanjum239@gmail.com>
---
drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
index faa6dbf0f..bf9d20b59 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c
@@ -398,8 +398,8 @@ int mtk_build_eint(struct mtk_pinctrl *hw, struct platform_device *pdev)
for (i = hw->soc->nbase_names, j = 0; i < count_reg_names; i++, j++) {
hw->eint->base[j] = of_iomap(np, i);
- if (IS_ERR(hw->eint->base[j])) {
- ret = PTR_ERR(hw->eint->base[j]);
+ if (!hw->eint->base[j]) {
+ ret = -ENOMEM;
goto err_free_eint;
}
}
base-commit: a90ee4305c4a5df72c11b31dacfdc76e00fcf78a
--
2.50.1 (Apple Git-155)
reply other threads:[~2026-10-05 6:06 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=20261005060641.32674-1-saadanjum239@gmail.com \
--to=saadanjum239@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=matthias.bgg@gmail.com \
--cc=ot_chhao.chang@mediatek.com \
--cc=qingliang.li@mediatek.com \
--cc=sean.wang@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
all inboxes | Powered by JetHome®