Skip to content

Commit 2d5446d

Browse files
Guodong Liulinusw
authored andcommitted
pinctrl: mediatek: fix global-out-of-bounds issue
When eint virtual eint number is greater than gpio number, it maybe produce 'desc[eint_n]' size globle-out-of-bounds issue. Signed-off-by: Guodong Liu <[email protected]> Signed-off-by: Zhiyong Tao <[email protected]> Reviewed-by: Chen-Yu Tsai <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 1360572 commit 2d5446d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/pinctrl/mediatek/pinctrl-mtk-common-v2.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -285,8 +285,12 @@ static int mtk_xt_get_gpio_n(void *data, unsigned long eint_n,
285285
desc = (const struct mtk_pin_desc *)hw->soc->pins;
286286
*gpio_chip = &hw->chip;
287287

288-
/* Be greedy to guess first gpio_n is equal to eint_n */
289-
if (desc[eint_n].eint.eint_n == eint_n)
288+
/*
289+
* Be greedy to guess first gpio_n is equal to eint_n.
290+
* Only eint virtual eint number is greater than gpio number.
291+
*/
292+
if (hw->soc->npins > eint_n &&
293+
desc[eint_n].eint.eint_n == eint_n)
290294
*gpio_n = eint_n;
291295
else
292296
*gpio_n = mtk_xt_find_eint_num(hw, eint_n);

0 commit comments

Comments
 (0)