[PATCH] pinctrl: mediatek: common-v2: Fix of_iomap() error check

Saad Anjum saadanjum239 at gmail.com
Sun Oct 4 23:06:41 PDT 2026


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 at 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)




More information about the Linux-mediatek mailing list