提交 78d722b1 编写于 作者: Y YueHaibing 提交者: Luca Coelho

iwlwifi: Use struct_size() in kzalloc

Use struct_size() in kzalloc instead of the 'regd_to_copy'
Signed-off-by: NYueHaibing <yuehaibing@huawei.com>
Signed-off-by: NLuca Coelho <luciano.coelho@intel.com>
上级 4b49e34e
...@@ -1086,7 +1086,6 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, ...@@ -1086,7 +1086,6 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
u32 reg_rule_flags, prev_reg_rule_flags = 0; u32 reg_rule_flags, prev_reg_rule_flags = 0;
const u16 *nvm_chan; const u16 *nvm_chan;
struct ieee80211_regdomain *regd, *copy_rd; struct ieee80211_regdomain *regd, *copy_rd;
int size_of_regd, regd_to_copy;
struct ieee80211_reg_rule *rule; struct ieee80211_reg_rule *rule;
struct regdb_ptrs *regdb_ptrs; struct regdb_ptrs *regdb_ptrs;
enum nl80211_band band; enum nl80211_band band;
...@@ -1116,11 +1115,7 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, ...@@ -1116,11 +1115,7 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
num_of_ch); num_of_ch);
/* build a regdomain rule for every valid channel */ /* build a regdomain rule for every valid channel */
size_of_regd = regd = kzalloc(struct_size(regd, reg_rules, num_of_ch), GFP_KERNEL);
sizeof(struct ieee80211_regdomain) +
num_of_ch * sizeof(struct ieee80211_reg_rule);
regd = kzalloc(size_of_regd, GFP_KERNEL);
if (!regd) if (!regd)
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -1196,10 +1191,8 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg, ...@@ -1196,10 +1191,8 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
* Narrow down regdom for unused regulatory rules to prevent hole * Narrow down regdom for unused regulatory rules to prevent hole
* between reg rules to wmm rules. * between reg rules to wmm rules.
*/ */
regd_to_copy = sizeof(struct ieee80211_regdomain) + copy_rd = kmemdup(regd, struct_size(regd, reg_rules, valid_rules),
valid_rules * sizeof(struct ieee80211_reg_rule); GFP_KERNEL);
copy_rd = kmemdup(regd, regd_to_copy, GFP_KERNEL);
if (!copy_rd) { if (!copy_rd) {
copy_rd = ERR_PTR(-ENOMEM); copy_rd = ERR_PTR(-ENOMEM);
goto out; goto out;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册