mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-29 11:11:45 -04:00
pinctrl: at91: Fix possible out-of-boundary access
[ Upstream commit 762ef7d1e6eefad9896560bfcb9bcf7f1b6df9c1 ]
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 <[email protected]>
Closes: https://lore.kernel.org/r/[email protected]/
Link: https://lore.kernel.org/[email protected]
Signed-off-by: Linus Walleij <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
This commit is contained in:
parent
ac7fca667b
commit
264a5cf0c4
1 changed files with 5 additions and 1 deletions
|
|
@ -1819,12 +1819,16 @@ static int at91_gpio_probe(struct platform_device *pdev)
|
|||
struct at91_gpio_chip *at91_chip = NULL;
|
||||
struct gpio_chip *chip;
|
||||
struct pinctrl_gpio_range *range;
|
||||
int alias_idx;
|
||||
int ret = 0;
|
||||
int irq, i;
|
||||
int alias_idx = of_alias_get_id(np, "gpio");
|
||||
uint32_t ngpio;
|
||||
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));
|
||||
if (gpio_chips[alias_idx]) {
|
||||
ret = -EBUSY;
|
||||
|
|
|
|||
Loading…
Reference in a new issue