summaryrefslogtreecommitdiffstats
path: root/drivers/net/wireless/intel/iwlwifi
diff options
context:
space:
mode:
authorGustavo A. R. Silva2019-04-03 18:03:42 +0200
committerLuca Coelho2019-06-29 09:09:38 +0200
commite344896723562d1288ba76cc8f232718b9a435f7 (patch)
treee4be43443561d80b0abe405b0d27e8688fe5718c /drivers/net/wireless/intel/iwlwifi
parentiwlwifi: lib: Use struct_size() helper (diff)
downloadkernel-qcow2-linux-e344896723562d1288ba76cc8f232718b9a435f7.tar.gz
kernel-qcow2-linux-e344896723562d1288ba76cc8f232718b9a435f7.tar.xz
kernel-qcow2-linux-e344896723562d1288ba76cc8f232718b9a435f7.zip
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>
Diffstat (limited to 'drivers/net/wireless/intel/iwlwifi')
-rw-r--r--drivers/net/wireless/intel/iwlwifi/mvm/d3.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
index e7e68fb2bd29..55f73184ee0c 100644
--- a/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
+++ b/drivers/net/wireless/intel/iwlwifi/mvm/d3.c
@@ -398,8 +398,7 @@ static int iwl_mvm_send_patterns_v1(struct iwl_mvm *mvm,
if (!wowlan->n_patterns)
return 0;
- cmd.len[0] = sizeof(*pattern_cmd) +
- wowlan->n_patterns * sizeof(struct iwl_wowlan_pattern_v1);
+ cmd.len[0] = struct_size(pattern_cmd, patterns, wowlan->n_patterns);
pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL);
if (!pattern_cmd)