Re: [PATCH 2/2][next] wifi: brcmfmac: Use struct_size() and array_size() in code ralated to struct brcmf_gscan_config

From: Kees Cook
Date: Thu Nov 17 2022 - 18:17:36 EST


On Mon, Nov 14, 2022 at 05:02:06PM -0600, Gustavo A. R. Silva wrote:
> Prefer struct_size() over open-coded versions of idiom:
>
> sizeof(struct-with-flex-array) + sizeof(typeof-flex-array-elements) * count
>
> where count is the max number of items the flexible array is supposed to
> contain.
>
> Also, use array_size() in call to memcpy().
>
> Link: https://github.com/KSPP/linux/issues/160
> Signed-off-by: Gustavo A. R. Silva <gustavoars@xxxxxxxxxx>

Reviewed-by: Kees Cook <keescook@xxxxxxxxxxxx>

--
Kees Cook