mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2025-09-18 22:14:16 +00:00
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: 6732ae5cb4
("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>
This commit is contained in:
parent
3b38cce83f
commit
762ef7d1e6
1 changed files with 5 additions and 1 deletions
|
@ -1822,12 +1822,16 @@ static int at91_gpio_probe(struct platform_device *pdev)
|
||||||
struct at91_gpio_chip *at91_chip = NULL;
|
struct at91_gpio_chip *at91_chip = NULL;
|
||||||
struct gpio_chip *chip;
|
struct gpio_chip *chip;
|
||||||
struct pinctrl_gpio_range *range;
|
struct pinctrl_gpio_range *range;
|
||||||
|
int alias_idx;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int irq, i;
|
int irq, i;
|
||||||
int alias_idx = of_alias_get_id(np, "gpio");
|
|
||||||
uint32_t ngpio;
|
uint32_t ngpio;
|
||||||
char **names;
|
char **names;
|
||||||
|
|
||||||
|
alias_idx = of_alias_get_id(np, "gpio");
|
||||||
|
if (alias_idx < 0)
|
||||||
|
return alias_idx;
|
||||||
|
|
||||||
BUG_ON(alias_idx >= ARRAY_SIZE(gpio_chips));
|
BUG_ON(alias_idx >= ARRAY_SIZE(gpio_chips));
|
||||||
if (gpio_chips[alias_idx])
|
if (gpio_chips[alias_idx])
|
||||||
return dev_err_probe(dev, -EBUSY, "%d slot is occupied.\n", alias_idx);
|
return dev_err_probe(dev, -EBUSY, "%d slot is occupied.\n", alias_idx);
|
||||||
|
|
Loading…
Add table
Reference in a new issue