mirror of
https://github.com/torvalds/linux.git
synced 2024-12-23 03:11:46 +00:00
iwlwifi: d3: Use struct_size() helper
Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes, in particular in the context in which this code is being used. So, change the following form: sizeof(*pattern_cmd) + wowlan->n_patterns * sizeof(struct iwlagn_wowlan_pattern) to : struct_size(pattern_cmd, patterns, wowlan->n_patterns) This code was detected with the help of Coccinelle. Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com> Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
This commit is contained in:
parent
8283f4f85c
commit
e344896723
@ -398,8 +398,7 @@ static int iwl_mvm_send_patterns_v1(struct iwl_mvm *mvm,
|
|||||||
if (!wowlan->n_patterns)
|
if (!wowlan->n_patterns)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
cmd.len[0] = sizeof(*pattern_cmd) +
|
cmd.len[0] = struct_size(pattern_cmd, patterns, wowlan->n_patterns);
|
||||||
wowlan->n_patterns * sizeof(struct iwl_wowlan_pattern_v1);
|
|
||||||
|
|
||||||
pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL);
|
pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL);
|
||||||
if (!pattern_cmd)
|
if (!pattern_cmd)
|
||||||
|
Loading…
Reference in New Issue
Block a user