* [PATCH v1 1/1] pinctrl: at91: Fix possible out-of-boundary access
@ 2025-05-08 20:08 Andy Shevchenko
2025-05-10 18:30 ` Andy Shevchenko
2025-05-13 13:27 ` Linus Walleij
0 siblings, 2 replies; 3+ messages in thread
From: Andy Shevchenko @ 2025-05-08 20:08 UTC (permalink / raw)
To: Linus Walleij, linux-arm-kernel, linux-gpio, linux-kernel
Cc: Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea, Andy Shevchenko
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>
---
drivers/pinctrl/pinctrl-at91.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c
index 442dd8c80b65..6c2727bd55bc 100644
--- a/drivers/pinctrl/pinctrl-at91.c
+++ b/drivers/pinctrl/pinctrl-at91.c
@@ -1822,12 +1822,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])
return dev_err_probe(dev, -EBUSY, "%d slot is occupied.\n", alias_idx);
--
2.47.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/1] pinctrl: at91: Fix possible out-of-boundary access
2025-05-08 20:08 [PATCH v1 1/1] pinctrl: at91: Fix possible out-of-boundary access Andy Shevchenko
@ 2025-05-10 18:30 ` Andy Shevchenko
2025-05-13 13:27 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Andy Shevchenko @ 2025-05-10 18:30 UTC (permalink / raw)
To: Andy Shevchenko
Cc: Linus Walleij, linux-arm-kernel, linux-gpio, linux-kernel,
Ludovic Desroches, Nicolas Ferre, Alexandre Belloni,
Claudiu Beznea
Thu, May 08, 2025 at 11:08:07PM +0300, Andy Shevchenko kirjoitti:
> 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.
Also
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202505052343.UHF1Zo93-lkp@intel.com/
> Fixes: 6732ae5cb47c ("ARM: at91: add pinctrl support")
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH v1 1/1] pinctrl: at91: Fix possible out-of-boundary access
2025-05-08 20:08 [PATCH v1 1/1] pinctrl: at91: Fix possible out-of-boundary access Andy Shevchenko
2025-05-10 18:30 ` Andy Shevchenko
@ 2025-05-13 13:27 ` Linus Walleij
1 sibling, 0 replies; 3+ messages in thread
From: Linus Walleij @ 2025-05-13 13:27 UTC (permalink / raw)
To: Andy Shevchenko
Cc: linux-arm-kernel, linux-gpio, linux-kernel, Ludovic Desroches,
Nicolas Ferre, Alexandre Belloni, Claudiu Beznea
On Thu, May 8, 2025 at 10:08 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> 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>
Patch applied and hey, b4 just picked up all the extra tags for me!
Love this tool.
Yours,
Linus Walleij
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-05-13 13:28 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-08 20:08 [PATCH v1 1/1] pinctrl: at91: Fix possible out-of-boundary access Andy Shevchenko
2025-05-10 18:30 ` Andy Shevchenko
2025-05-13 13:27 ` Linus Walleij
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).