Re: [PATCH v3] leds: pwm: Annotate leds[] with __counted_by()

Mert Seftali <[email protected]>
Newsgroups org.kernel.vger.linux-leds,dev.linux.lists.sashiko-reviews
Message-ID <CAA3Noor8kEMPbjAOf8UWz4LQ=n9H80=1L42wseOGH-3HGa7-XA@mail.gmail.com>
Hi Lee,

Sashiko is right and I tested it too now to confirm. Under UBSAN_BOUNDS
&priv->leds[i] traps on an out-of-range index, but the led_data++ walk
in v3 does not: decaying the array to a plain led_pwm_data * drops the
__counted_by association, so num_leds is only enforced on subscript
accesses and v3 has none.

Getting the check back means &priv->leds[i] subscripting. I can still
pass that element into led_pwm_add() as you suggested, it just brings a
loop index back. So it is a tradeoff: the cleaner pointer form, or the
annotation actually enforced.

Since the element-passing was your suggestion, which would you prefer:
keep the pointer walk (annotation stays documentary), or respin with
subscripting so num_leds is enforced? Happy to do either.

Thanks,
Mert
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.