diff options
author | Gustavo A. R. Silva <gustavo@embeddedor.com> | 2019-04-03 10:59:01 -0500 |
---|---|---|
committer | Luca Coelho <luciano.coelho@intel.com> | 2019-06-29 10:09:38 +0300 |
commit | 8283f4f85c49129ca2c4e682848afc09c7dec949 (patch) | |
tree | b24a070828c360e5285ea25326944a54afd1a292 /drivers/net/wireless/intel/iwlwifi/dvm | |
parent | 3e832fd10f7f1e26f1fb34797c06a01abc37fa63 (diff) |
iwlwifi: lib: 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/dvm')
-rw-r--r-- | drivers/net/wireless/intel/iwlwifi/dvm/lib.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/net/wireless/intel/iwlwifi/dvm/lib.c b/drivers/net/wireless/intel/iwlwifi/dvm/lib.c index 1fd6bf578474..eab94d2f46b1 100644 --- a/drivers/net/wireless/intel/iwlwifi/dvm/lib.c +++ b/drivers/net/wireless/intel/iwlwifi/dvm/lib.c @@ -1009,8 +1009,7 @@ int iwlagn_send_patterns(struct iwl_priv *priv, if (!wowlan->n_patterns) return 0; - cmd.len[0] = sizeof(*pattern_cmd) + - wowlan->n_patterns * sizeof(struct iwlagn_wowlan_pattern); + cmd.len[0] = struct_size(pattern_cmd, patterns, wowlan->n_patterns); pattern_cmd = kmalloc(cmd.len[0], GFP_KERNEL); if (!pattern_cmd) |