summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Lechner <[email protected]>2026-02-09 17:34:17 -0600
committerDavid Lechner <[email protected]>2026-03-11 10:42:03 -0500
commit64d48d21b51c65c01a842153dee0de70fe769145 (patch)
treefb7799b74f74e34ea9d4b4cb9ae7b1ee393a4888
parentb2a1db57ebed72f93b614acfd41b3cf56a504ee5 (diff)
pinctl: mediatek: add bounds check on number of base addresses
Add a bounds check on the number of base addresses to prevent out-of-bounds access to the priv->base array. Reviewed-by: Macpaul Lin <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: David Lechner <[email protected]>
-rw-r--r--drivers/pinctrl/mediatek/pinctrl-mtk-common.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
index e991e03ea41..d152e216634 100644
--- a/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
+++ b/drivers/pinctrl/mediatek/pinctrl-mtk-common.c
@@ -856,6 +856,9 @@ int mtk_pinctrl_common_probe(struct udevice *dev,
if (!base_calc)
nbase_names = 1;
+ if (nbase_names > MAX_BASE_CALC)
+ return -ENOSPC;
+
for (i = 0; i < nbase_names; i++) {
if (soc->base_names)
addr = dev_read_addr_name(dev, soc->base_names[i]);