]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
pinctrl: mediatek: set array size for reg_cals
authorDavid Lechner <dlechner@baylibre.com>
Tue, 13 Jan 2026 23:25:52 +0000 (17:25 -0600)
committerTom Rini <trini@konsulko.com>
Wed, 21 Jan 2026 19:29:25 +0000 (13:29 -0600)
Set the size of the reg_cals arrays to PINCTRL_PIN_REG_MAX to in all
affected mediatek pinctrl drivers. This is needed to avoid potential
out-of-bounds accesses when they is used in mtk_hw_pin_field_get().
All array members need to be initialized since the code loops from 0
to PINCTRL_PIN_REG_MAX - 1. mt7622_reg_cals was already defined this
way, but the others were not.

Signed-off-by: David Lechner <dlechner@baylibre.com>
drivers/pinctrl/mediatek/pinctrl-mt7623.c
drivers/pinctrl/mediatek/pinctrl-mt7629.c
drivers/pinctrl/mediatek/pinctrl-mt7981.c
drivers/pinctrl/mediatek/pinctrl-mt7986.c
drivers/pinctrl/mediatek/pinctrl-mt7987.c
drivers/pinctrl/mediatek/pinctrl-mt7988.c
drivers/pinctrl/mediatek/pinctrl-mt8365.c
drivers/pinctrl/mediatek/pinctrl-mt8512.c
drivers/pinctrl/mediatek/pinctrl-mt8516.c
drivers/pinctrl/mediatek/pinctrl-mt8518.c

index 55e49a790e46db9f66744932d616302569142af3..e9678cebd3c31ce6ddf0f3993cbe8f81c2e9402b 100644 (file)
@@ -388,7 +388,7 @@ static const struct mtk_pin_field_calc mt7623_pin_r0_range[] = {
        PIN_FIELD16(261, 261, 0x140, 0x10, 10, 1),
 };
 
-static const struct mtk_pin_reg_calc mt7623_reg_cals[] = {
+static const struct mtk_pin_reg_calc mt7623_reg_cals[PINCTRL_PIN_REG_MAX] = {
        [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7623_pin_mode_range),
        [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7623_pin_dir_range),
        [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7623_pin_di_range),
index 3b82423c1454df9ebb83b8bb97ec9a9bb1340d2e..d67220dc2f730bfa3139060e243600e82921c1ca 100644 (file)
@@ -80,7 +80,7 @@ static const struct mtk_pin_field_calc mt7629_pin_drv_range[] = {
        PIN_FIELD(70, 78, 0x7600, 0x10, 0, 4),
 };
 
-static const struct mtk_pin_reg_calc mt7629_reg_cals[] = {
+static const struct mtk_pin_reg_calc mt7629_reg_cals[PINCTRL_PIN_REG_MAX] = {
        [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7629_pin_mode_range),
        [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7629_pin_dir_range),
        [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7629_pin_di_range),
index 13c3dc143cb8fb2f12e5f1ed8a21f37e111fcd82..0d48994bd895e8eac2e5535bf54bbac747764bf4 100644 (file)
@@ -494,7 +494,7 @@ static const struct mtk_pin_field_calc mt7981_pin_r1_range[] = {
        PIN_FIELD_BASE(39, 39, 3, 0x40, 0x10, 1, 1),
 };
 
-static const struct mtk_pin_reg_calc mt7981_reg_cals[] = {
+static const struct mtk_pin_reg_calc mt7981_reg_cals[PINCTRL_PIN_REG_MAX] = {
        [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7981_pin_mode_range),
        [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7981_pin_dir_range),
        [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7981_pin_di_range),
index bf8cd037535f66b257608ef71571df64e76b389b..61ce2ec8ac1e67372e95824f5dcb4fa2040a1999 100644 (file)
@@ -415,7 +415,7 @@ static const struct mtk_pin_field_calc mt7986_pin_r1_range[] = {
        PIN_FIELD_BASE(66, 68, IOCFG_LB_BASE, 0x60, 0x10, 2, 1),
 };
 
-static const struct mtk_pin_reg_calc mt7986_reg_cals[] = {
+static const struct mtk_pin_reg_calc mt7986_reg_cals[PINCTRL_PIN_REG_MAX] = {
        [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7986_pin_mode_range),
        [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7986_pin_dir_range),
        [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7986_pin_di_range),
index db672d26798b21cb72d6617cfc6d6c61fb55a91d..92b43cf3b55a4caac14575c2d022bed89e8c86ab 100644 (file)
@@ -386,7 +386,7 @@ static const struct mtk_pin_field_calc mt7987_pin_r1_range[] = {
        PIN_FIELD_BASE(49, 49, IOCFG_TL_BASE, 0x50, 0x10, 8, 1),
 };
 
-static const struct mtk_pin_reg_calc mt7987_reg_cals[] = {
+static const struct mtk_pin_reg_calc mt7987_reg_cals[PINCTRL_PIN_REG_MAX] = {
        [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7987_pin_mode_range),
        [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7987_pin_dir_range),
        [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7987_pin_di_range),
index 639e2415c630292a14f274875a3e81ca200c427d..74655493414b6d28190f00ef77125b8b06f0ef5a 100644 (file)
@@ -606,7 +606,7 @@ static const struct mtk_pin_field_calc mt7988_pin_r1_range[] = {
        PIN_FIELD_BASE(83, 83, IOCFG_TR_BASE, 0x90, 0x10, 15, 1),
 };
 
-static const struct mtk_pin_reg_calc mt7988_reg_cals[] = {
+static const struct mtk_pin_reg_calc mt7988_reg_cals[PINCTRL_PIN_REG_MAX] = {
        [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt7988_pin_mode_range),
        [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt7988_pin_dir_range),
        [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt7988_pin_di_range),
index 0eae85b00781f498cdd70f2e242116488c175d20..2e29150158402f8250f40544de1b6cfd2a2c442f 100644 (file)
@@ -223,7 +223,7 @@ static const struct mtk_pin_field_calc mt8365_pin_drv_range[] = {
        PIN_FIELD_DRV(136, 144, 0x770, 24),
 };
 
-static const struct mtk_pin_reg_calc mt8365_reg_cals[] = {
+static const struct mtk_pin_reg_calc mt8365_reg_cals[PINCTRL_PIN_REG_MAX] = {
        [PINCTRL_PIN_REG_MODE]    = MTK_RANGE(mt8365_pin_mode_range),
        [PINCTRL_PIN_REG_DIR]     = MTK_RANGE(mt8365_pin_dir_range),
        [PINCTRL_PIN_REG_DI]      = MTK_RANGE(mt8365_pin_di_range),
index 5a8dd4ddd406a58dbcf9370599177997b5599de9..4fb15815d86ef12b004e80a6f50633aba72aba9e 100644 (file)
@@ -178,7 +178,7 @@ static const struct mtk_pin_field_calc mt8512_pin_drv_range[] = {
        PIN_FIELDS(112, 115, 0x760, 0x10, 16, 4),
 };
 
-static const struct mtk_pin_reg_calc mt8512_reg_cals[] = {
+static const struct mtk_pin_reg_calc mt8512_reg_cals[PINCTRL_PIN_REG_MAX] = {
        [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8512_pin_mode_range),
        [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8512_pin_dir_range),
        [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt8512_pin_di_range),
index 9c25066fc2dd76f8c2e2026203d5b662f6db8b4a..09d71d45c89318271d036e17e5b2bb08062ef7db 100644 (file)
@@ -184,7 +184,7 @@ static const struct mtk_pin_field_calc mt8516_pin_drv_range[] = {
        PIN_FIELD(117, 120, 0xd70, 0x10, 0, 4),
 };
 
-static const struct mtk_pin_reg_calc mt8516_reg_cals[] = {
+static const struct mtk_pin_reg_calc mt8516_reg_cals[PINCTRL_PIN_REG_MAX] = {
        [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8516_pin_mode_range),
        [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8516_pin_dir_range),
        [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt8516_pin_di_range),
index 333184a6bb21da18edbac23a6b030b1e07fcfe2d..0367e739e8e913e80a06b42a0aabdbc355ad27e7 100644 (file)
@@ -205,7 +205,7 @@ static const struct mtk_pin_field_calc mt8518_pin_drv_range[] = {
        PIN_FIELD(116, 119, 0xd60, 0x10, 4, 4),
 };
 
-static const struct mtk_pin_reg_calc mt8518_reg_cals[] = {
+static const struct mtk_pin_reg_calc mt8518_reg_cals[PINCTRL_PIN_REG_MAX] = {
        [PINCTRL_PIN_REG_MODE] = MTK_RANGE(mt8518_pin_mode_range),
        [PINCTRL_PIN_REG_DIR] = MTK_RANGE(mt8518_pin_dir_range),
        [PINCTRL_PIN_REG_DI] = MTK_RANGE(mt8518_pin_di_range),