[PATCH 1/3] pinctl: mediatek: add bounds check on number of base addresses

Macpaul Lin (林智斌) Macpaul.Lin at mediatek.com
Fri Mar 6 09:49:31 CET 2026


On Mon, 2026-02-09 at 17:34 -0600, David Lechner wrote:
> Add a bounds check on the number of base addresses to prevent
> out-of-bounds access to the priv->base array.
> 
> Signed-off-by: David Lechner <dlechner at baylibre.com>
> ---
>  drivers/pinctrl/mediatek/pinctrl-mtk-common.c | 3 +++
>  1 file changed, 3 insertions(+)
> 
> 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]);
> 

Reviewed-by: Macpaul Lin <macpaul.lin at mediatek.com>

Thanks!
Macpaul Lin


More information about the U-Boot mailing list