Re: [PATCH] gpiolib: annotate struct acpi_gpio_mapping with __counted_by_ptr

From: Linus Walleij

Date: Sun Nov 08 2026 - 10:54:03 EST


On Mon, Sep 28, 2026 at 8:38 AM Bill Wendling <morbo@xxxxxxxxxx> wrote:

> The 'data' pointer field in 'struct acpi_gpio_mapping' is associated
> with the 'size' field, which represents the number of elements of
> type 'struct acpi_gpio_params' allocated for 'data'.
>
> To improve bounds checking via CONFIG_UBSAN_BOUNDS and
> CONFIG_FORTIFY_SOURCE, annotate 'data' with the __counted_by_ptr
> attribute.
>
> Analysis of allocation, assignment, and access points shows that the
> pointer is never accessed before the count is set, which guarantees that
> this annotation is safe and will not cause runtime panics or
> false-positive bounds checks.
>
> Cc: codemender-patching+linux@xxxxxxxxxx
> Assisted-by: LLM
> Signed-off-by: Bill Wendling <morbo@xxxxxxxxxx>

Prerequisites handled in EFI so:
Reviewed-by: Linus Walleij <linusw@xxxxxxxxxx>

Yours,
Linus Walleij