]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
pinctl: mediatek: add bounds check on number of base addresses
authorDavid Lechner <dlechner@baylibre.com>
Mon, 9 Feb 2026 23:34:17 +0000 (17:34 -0600)
committerDavid Lechner <dlechner@baylibre.com>
Wed, 11 Mar 2026 15:42:03 +0000 (10:42 -0500)
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 <macpaul.lin@mediatek.com>
Link: https://patch.msgid.link/20260209-mtk-pinctl-mt8189-v1-1-a7a3069eda6c@baylibre.com
Signed-off-by: David Lechner <dlechner@baylibre.com>
drivers/pinctrl/mediatek/pinctrl-mtk-common.c

index e991e03ea41faf9e8fb86e9e2d357f79b2fc01e7..d152e2166348d361b9b20c6a1e16f281cecbe278 100644 (file)
@@ -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]);