lkml.org 
[lkml]   [2022]   [Nov]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
SubjectRe: [PATCH 2/2][next] wifi: brcmfmac: Use struct_size() in code ralated to struct brcmf_dload_data_le
From


On 11/16/22 16:23, Kees Cook wrote:
> On Tue, Nov 15, 2022 at 03:55:34PM -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.
>>
>> In this particular case, in the open-coded version sizeof(typeof-flex-array-elements)
>> is implicit in _count_ because the type of the flex array data is u8:
>>
>> drivers/net/wireless/broadcom/brcm80211/brcmfmac/fwil_types.h:941:
>> 941 struct brcmf_dload_data_le {
>> 942 __le16 flag;
>> 943 __le16 dload_type;
>> 944 __le32 len;
>> 945 __le32 crc;
>> 946 u8 data[];
>> 947 };
>>
>> Link: https://github.com/KSPP/linux/issues/160
>> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
>
> Reviewed-by: Kees Cook <keescook@chromium.org>
>

Thanks for the reviews! :)

--
Gustavo

\
 
 \ /
  Last update: 2022-11-17 03:54    [W:0.061 / U:0.060 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site