Blame SOURCES/0005-Revert-iwlwifi-Use-struct_size-in-kzalloc.patch

deb259
From ba8ead2d7e896f57ea37bad77dd653cc0c7c81f1 Mon Sep 17 00:00:00 2001
deb259
From: Eugene Syromiatnikov <esyr@redhat.com>
deb259
Date: Thu, 11 Jul 2019 18:34:59 +0200
deb259
Subject: [PATCH] Revert "iwlwifi: Use struct_size() in kzalloc"
deb259
deb259
This reverts commit 78d722b1bdd96b31bbe886a2cb2e69ce7b350347.
deb259
---
deb259
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 13 ++++++++++---
deb259
 1 file changed, 10 insertions(+), 3 deletions(-)
deb259
deb259
diff --git a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
deb259
index 2a879e0b331f..f3ada226c008 100644
deb259
--- a/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
deb259
+++ b/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
deb259
@@ -1081,6 +1081,7 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
deb259
 	u32 reg_rule_flags, prev_reg_rule_flags = 0;
deb259
 	const u16 *nvm_chan;
deb259
 	struct ieee80211_regdomain *regd, *copy_rd;
deb259
+	int size_of_regd, regd_to_copy;
deb259
 	struct ieee80211_reg_rule *rule;
deb259
 	struct regdb_ptrs *regdb_ptrs;
deb259
 	enum nl80211_band band;
deb259
@@ -1110,7 +1111,11 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
deb259
 		      num_of_ch);
deb259
 
deb259
 	/* build a regdomain rule for every valid channel */
deb259
-	regd = kzalloc(struct_size(regd, reg_rules, num_of_ch), GFP_KERNEL);
deb259
+	size_of_regd =
deb259
+		sizeof(struct ieee80211_regdomain) +
deb259
+		num_of_ch * sizeof(struct ieee80211_reg_rule);
deb259
+
deb259
+	regd = kzalloc(size_of_regd, GFP_KERNEL);
deb259
 	if (!regd)
deb259
 		return ERR_PTR(-ENOMEM);
deb259
 
deb259
@@ -1186,8 +1191,10 @@ iwl_parse_nvm_mcc_info(struct device *dev, const struct iwl_cfg *cfg,
deb259
 	 * Narrow down regdom for unused regulatory rules to prevent hole
deb259
 	 * between reg rules to wmm rules.
deb259
 	 */
deb259
-	copy_rd = kmemdup(regd, struct_size(regd, reg_rules, valid_rules),
deb259
-			  GFP_KERNEL);
deb259
+	regd_to_copy = sizeof(struct ieee80211_regdomain) +
deb259
+		valid_rules * sizeof(struct ieee80211_reg_rule);
deb259
+
deb259
+	copy_rd = kmemdup(regd, regd_to_copy, GFP_KERNEL);
deb259
 	if (!copy_rd) {
deb259
 		copy_rd = ERR_PTR(-ENOMEM);
deb259
 		goto out;
deb259
-- 
deb259
2.13.6
deb259