* [PATCH] pinctrl: mediatek: common-v2: Fix of_iomap() error check
@ 2026-10-05 6:06 Saad Anjum
0 siblings, 0 replies; only message in thread
From: Saad Anjum @ 2026-10-05 6:06 UTC (permalink / raw)
To: Linus Walleij, Sean Wang
Cc: AngeloGioacchino Del Regno, Matthias Brugger, Hao Chang,
Qingliang Li, linux-gpio, linux-mediatek, linux-arm-kernel,
linux-kernel, Saad Anjum
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)
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-05 6:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-10-05 6:06 [PATCH] pinctrl: mediatek: common-v2: Fix of_iomap() error check Saad Anjum
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®