Re: [PATCH v2] gpiolib: annotate struct acpi_gpio_mapping with __counted_by_ptr
From: Bill Wendling
Date: Mon Nov 09 2026 - 09:26:21 EST
On Mon, Nov 9, 2026 at 1:21 AM Bartosz Golaszewski <brgl@xxxxxxxxxx> wrote:
>
> 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.
>
Okay. Do you need me to send a new version?
> > 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).
>
The "v2" is NOT the version that should be integrated. I said the
original patch. "v2" was sent as part of the discussion we were having
how to solve the issue that cropped up, and not meant to be the
defacto version.
-bw