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

From: Bartosz Golaszewski

Date: Mon Nov 09 2026 - 04:25:55 EST


On Fri, Oct 02, 2026 at 12:42:25PM +0000, Bill Wendling 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

This can be dropped now.

> Signed-off-by: Bill Wendling <morbo@xxxxxxxxxx>
> ---
> v2: Undefine "__counted_by" and "__counted_by_ptr" in the EFI stub
> library as it doesn't need it and Clang is missing a flag to
> enable them.
> ---

Plase, don't send new versions of patches as replies to previous
threads, this confuses tools (and maintainers).

Bart