Kees Cook <keesc...@chromium.org> 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:
> 
> ../drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c: In function 
> 'brcmf_internal_escan_add_info':
> ../drivers/net/wireless/broadcom/brcm80211/brcmfmac/cfg80211.c:3783:46: 
> warning: operation on 'req->
> n_channels' may be undefined [-Wsequence-point]
>  3783 |                 req->channels[req->n_channels++] = chan;
>       |                               ~~~~~~~~~~~~~~~^~
> 
> Fixes: e3eac9f32ec0 ("wifi: cfg80211: Annotate struct cfg80211_scan_request 
> with __counted_by")
> Cc: Arend van Spriel <aspr...@gmail.com>
> Cc: Franky Lin <franky....@broadcom.com>
> Cc: Hante Meuleman <hante.meule...@broadcom.com>
> Cc: Kalle Valo <kv...@kernel.org>
> Cc: Chi-hsien Lin <chi-hsien....@infineon.com>
> Cc: Ian Lin <ian....@infineon.com>
> Cc: Johannes Berg <johannes.b...@intel.com>
> Cc: Wright Feng <wright.f...@cypress.com>
> Cc: Hector Martin <mar...@marcan.st>
> Cc: linux-wirel...@vger.kernel.org
> Cc: brcm80211-dev-list....@broadcom.com
> Signed-off-by: Kees Cook <keesc...@chromium.org>
> Reviewed-by: Hans de Goede <hdego...@redhat.com>
> Reviewed-by: Linus Walleij <linus.wall...@linaro.org>
> Reviewed-by: Gustavo A. R. Silva <gustavo...@kernel.org>

I'm planning to queue this for wireless tree. Arend, ack?

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20240126223150.work.548-k...@kernel.org/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


Reply via email to