Re: [PATCH v3 1/2] gpiolib: acpi: Add robust bounds-checking for GPIO pin resources
From: Andy Shevchenko
Date: Tue Jun 02 2026 - 03:47:29 EST
On Wed, May 20, 2026 at 09:45:46AM +0200, Marco Scardovi (scardracs) wrote:
> Ensure that the GPIO pin resource arrays are safely bounded before
> accessing indices. Add bounds checking in acpi_request_own_gpiod(),
> acpi_gpio_irq_is_wake(), and acpi_gpiochip_alloc_event() to prevent
> out-of-bounds array reads if the ACPI namespace provides malformed or
> empty pin tables.
...
> - int polarity = GPIO_ACTIVE_HIGH;
> - enum gpiod_flags flags = acpi_gpio_to_gpiod_flags(agpio, polarity);
> + enum gpiod_flags flags;
> + int polarity;
What's the point?
...
> + polarity = GPIO_ACTIVE_HIGH;
> + flags = acpi_gpio_to_gpiod_flags(agpio, polarity);
> +
> + if (index >= agpio->pin_table_length)
> + return ERR_PTR(-EINVAL);
Now, what's the point of assigning flags and polarity before check? If you move
them after pin assignment below it will justify the changes in the definition
block above.
> + pin = agpio->pin_table[index];
--
With Best Regards,
Andy Shevchenko