Blame SOURCES/0080-Revert-iwlwifi-nvm-parse-use-struct_size-in-kzalloc.patch

deb259
From 2d91368aef2a73d37acdea30cd7086356e81ccc5 Mon Sep 17 00:00:00 2001
deb259
From: Eugene Syromiatnikov <esyr@redhat.com>
deb259
Date: Fri, 6 Sep 2019 01:50:55 +0200
deb259
Subject: [PATCH 1/7] Revert "iwlwifi: nvm-parse: use struct_size() in
deb259
 kzalloc()"
deb259
deb259
This reverts commit 6b367c9f88b0813f6a557e688b665324499a159e.
deb259
---
deb259
 drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c | 18 +++++++++++-------
deb259
 1 file changed, 11 insertions(+), 7 deletions(-)
deb259
deb259
Index: src/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c
deb259
===================================================================
deb259
--- src.orig/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c	2019-09-06 01:47:45.924301459 +0200
deb259
+++ src/drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c	2019-09-06 01:54:58.093737377 +0200
deb259
@@ -748,13 +748,15 @@
deb259
 	const __le16 *ch_section;
deb259
 
deb259
 	if (cfg->nvm_type != IWL_NVM_EXT)
deb259
-		data = kzalloc(struct_size(data, channels,
deb259
-					   IWL_NVM_NUM_CHANNELS),
deb259
-					   GFP_KERNEL);
deb259
+		data = kzalloc(sizeof(*data) +
deb259
+			       sizeof(struct ieee80211_channel) *
deb259
+			       IWL_NVM_NUM_CHANNELS,
deb259
+			       GFP_KERNEL);
deb259
 	else
deb259
-		data = kzalloc(struct_size(data, channels,
deb259
-					   IWL_NVM_NUM_CHANNELS_EXT),
deb259
-					   GFP_KERNEL);
deb259
+		data = kzalloc(sizeof(*data) +
deb259
+			       sizeof(struct ieee80211_channel) *
deb259
+			       IWL_NVM_NUM_CHANNELS_EXT,
deb259
+			       GFP_KERNEL);
deb259
 	if (!data)
deb259
 		return NULL;
deb259
 
deb259
@@ -1256,7 +1258,9 @@
deb259
 	if (empty_otp)
deb259
 		IWL_INFO(trans, "OTP is empty\n");
deb259
 
deb259
-	nvm = kzalloc(struct_size(nvm, channels, IWL_NUM_CHANNELS), GFP_KERNEL);
deb259
+	nvm = kzalloc(sizeof(*nvm) +
deb259
+		      sizeof(struct ieee80211_channel) * IWL_NUM_CHANNELS,
deb259
+		      GFP_KERNEL);
deb259
 	if (!nvm) {
deb259
 		ret = -ENOMEM;
deb259
 		goto out;