Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

pinctrl: at91: Fix possible out-of-boundary access

at91_gpio_probe() doesn't check that given OF alias is not available or
something went wrong when trying to get it. This might have consequences
when accessing gpio_chips array with that value as an index. Note, that
BUG() can be compiled out and hence won't actually perform the required
checks.

Fixes: 6732ae5cb47c ("ARM: at91: add pinctrl support")
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Closes: https://lore.kernel.org/r/202505052343.UHF1Zo93-lkp@intel.com/
Link: https://lore.kernel.org/20250508200807.1384558-1-andriy.shevchenko@linux.intel.com
Signed-off-by: Linus Walleij <linus.walleij@linaro.org>

authored by

Andy Shevchenko and committed by
Linus Walleij
762ef7d1 3b38cce8

+5 -1
+5 -1
drivers/pinctrl/pinctrl-at91.c
··· 1822 1822 struct at91_gpio_chip *at91_chip = NULL; 1823 1823 struct gpio_chip *chip; 1824 1824 struct pinctrl_gpio_range *range; 1825 + int alias_idx; 1825 1826 int ret = 0; 1826 1827 int irq, i; 1827 - int alias_idx = of_alias_get_id(np, "gpio"); 1828 1828 uint32_t ngpio; 1829 1829 char **names; 1830 + 1831 + alias_idx = of_alias_get_id(np, "gpio"); 1832 + if (alias_idx < 0) 1833 + return alias_idx; 1830 1834 1831 1835 BUG_ON(alias_idx >= ARRAY_SIZE(gpio_chips)); 1832 1836 if (gpio_chips[alias_idx])