Re: [PATCH] wifi: brcmfmac: Adjust n_channels usage for __counted_by

From: Linus Walleij
Date: Sat Jan 27 2024 - 11:38:08 EST


On Fri, Jan 26, 2024 at 11:31 PM Kees Cook <keescook@xxxxxxxxxxxx> wrote:

> After commit e3eac9f32ec0 ("wifi: cfg80211: Annotate struct
> cfg80211_scan_request with __counted_by"), the compiler may enforce
> dynamic array indexing of req->channels to stay below n_channels. As a
> result, n_channels needs to be increased _before_ accessing the newly
> added array index. Increment it first, then use "i" for the prior index.
> Solves this warning in the coming GCC that has __counted_by support:

Makes perfect sense.
Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>

Yours,
Linus Walleij