These comparisons should be >= instead of > to prevent accessing one
element beyond the end of the hw->soc->pins[] array.
Fixes:
3de7deefce69 ("pinctrl: mediatek: Check gpio pin number and use binary search in mtk_hw_pin_field_lookup()")
Fixes:
184d8e13f9b1 ("pinctrl: mediatek: Add support for pin configuration dump via debugfs.")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Link: https://lore.kernel.org/r/20200218055247.74s2xa7veqx2do34@kili.mountain
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
const struct mtk_pin_desc *desc;
int value, err;
const struct mtk_pin_desc *desc;
int value, err;
- if (gpio > hw->soc->npins)
+ if (gpio >= hw->soc->npins)
return -EINVAL;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
return -EINVAL;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
int pinmux, pullup, pullen, len = 0, r1 = -1, r0 = -1;
const struct mtk_pin_desc *desc;
int pinmux, pullup, pullen, len = 0, r1 = -1, r0 = -1;
const struct mtk_pin_desc *desc;
- if (gpio > hw->soc->npins)
+ if (gpio >= hw->soc->npins)
return -EINVAL;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
return -EINVAL;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
const struct mtk_pin_desc *desc;
int value, err;
const struct mtk_pin_desc *desc;
int value, err;
- if (gpio > hw->soc->npins)
+ if (gpio >= hw->soc->npins)
return -EINVAL;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
return -EINVAL;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
const struct mtk_pin_desc *desc;
int value, err;
const struct mtk_pin_desc *desc;
int value, err;
- if (gpio > hw->soc->npins)
+ if (gpio >= hw->soc->npins)
return -EINVAL;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
return -EINVAL;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
const struct mtk_pin_desc *desc;
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
const struct mtk_pin_desc *desc;
- if (gpio > hw->soc->npins)
+ if (gpio >= hw->soc->npins)
return;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
return;
desc = (const struct mtk_pin_desc *)&hw->soc->pins[gpio];
{
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
{
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
- if (gpio > hw->soc->npins)
+ if (gpio >= hw->soc->npins)
return -EINVAL;
return pinctrl_gpio_direction_input(chip->base + gpio);
return -EINVAL;
return pinctrl_gpio_direction_input(chip->base + gpio);
{
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
{
struct mtk_pinctrl *hw = gpiochip_get_data(chip);
- if (gpio > hw->soc->npins)
+ if (gpio >= hw->soc->npins)
return -EINVAL;
mtk_gpio_set(chip, gpio, value);
return -EINVAL;
mtk_gpio_set(chip, gpio, value);