Skip to contentSkip to conversation

net/i40e: fix out-of-scope variable

PATCH Superseded Zhang,Alvin 3 participants 4 messages Jan 14, 2021 – Jan 19, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/i40e: fix out-of-scope variable

From: Alvin Zhang <[email protected]>

Using "key", which points to an out-of-scope variable "rss_key_default".

---
 drivers/net/i40e/i40e_hash.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_hash.c +4 -2
index e07f806..83a9af5 100644
@@ -901,10 +901,12 @@ struct i40e_hash_match_pattern {
 			PMD_DRV_LOG(WARNING,
 				    "RSS key length invalid, must be %u bytes, now set key to default",
 				    (uint32_t)sizeof(rss_conf->key));
-		key = (const uint8_t *)rss_key_default;
+
+		memcpy(rss_conf->key, rss_key_default, sizeof(rss_conf->key));
+	} else {
+		memcpy(rss_conf->key, key, sizeof(rss_conf->key));
 	}
 
-	memcpy(rss_conf->key, key, sizeof(rss_conf->key));
 	rss_conf->conf.key = rss_conf->key;
 	rss_conf->conf.key_len = sizeof(rss_conf->key);
 }
Signature · 1 line
1.8.3.1
#1 lore raw

PATCH v2 1/1 net/i40e: fix out-of-scope variable

From: Alvin Zhang <[email protected]>

Using "key", which points to an out-of-scope variable "rss_key_default".

Coverity issue: 365293

Fixes ef4c16fd9148 ("net/i40e: refactor RSS flow")

---

V2: Update the commit log.

---
 drivers/net/i40e/i40e_hash.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_hash.c +4 -2
index e07f806..83a9af5 100644
@@ -901,10 +901,12 @@ struct i40e_hash_match_pattern {
 			PMD_DRV_LOG(WARNING,
 				    "RSS key length invalid, must be %u bytes, now set key to default",
 				    (uint32_t)sizeof(rss_conf->key));
-		key = (const uint8_t *)rss_key_default;
+
+		memcpy(rss_conf->key, rss_key_default, sizeof(rss_conf->key));
+	} else {
+		memcpy(rss_conf->key, key, sizeof(rss_conf->key));
 	}
 
-	memcpy(rss_conf->key, key, sizeof(rss_conf->key));
 	rss_conf->conf.key = rss_conf->key;
 	rss_conf->conf.key_len = sizeof(rss_conf->key);
 }
Signature · 1 line
1.8.3.1
Acked-by on v2 1/1
#2 lore raw
Quoted 44 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Zhang,Alvin
Sent: Friday, January 15, 2021 4:34 PM
To: Guo, Jia <[email protected]>; Xie, WeiX <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>
Subject: [dpdk-dev] [PATCH v2] net/i40e: fix out-of-scope variable

From: Alvin Zhang <[email protected]>

Using "key", which points to an out-of-scope variable "rss_key_default".

Coverity issue: 365293

Fixes ef4c16fd9148 ("net/i40e: refactor RSS flow")

---

V2: Update the commit log.

---
 drivers/net/i40e/i40e_hash.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_hash.c index renamed from drivers/net/i40e/i40e_hash.c +0 -0

e07f806..83a9af5 100644

drivers/net/i40e/i40e_hash.c +4 -3
@@ -901,10 +901,12 @@ struct i40e_hash_match_pattern {
 			PMD_DRV_LOG(WARNING,
 				    "RSS key length invalid, must be %u bytes,
 now set key to default",
 				    (uint32_t)sizeof(rss_conf->key));
-		key = (const uint8_t *)rss_key_default;
+
+		memcpy(rss_conf->key, rss_key_default, sizeof(rss_conf->key));
+	} else {
+		memcpy(rss_conf->key, key, sizeof(rss_conf->key));
 	}
 
-	memcpy(rss_conf->key, key, sizeof(rss_conf->key));
 	rss_conf->conf.key = rss_conf->key;
 	rss_conf->conf.key_len = sizeof(rss_conf->key);  }
--
Quoted 1 line

1.8.3.1

Applied
#3 lore raw
Quoted 52 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Xing, Beilei
Sent: Monday, January 18, 2021 4:27 PM
To: Zhang, AlvinX <[email protected]>; Guo, Jia <[email protected]>; Xie, WeiX <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>
Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix out-of-scope variable

Quoted 28 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Zhang,Alvin
Sent: Friday, January 15, 2021 4:34 PM
To: Guo, Jia <[email protected]>; Xie, WeiX <[email protected]>
Cc: [email protected]; Zhang, AlvinX <[email protected]>
Subject: [dpdk-dev] [PATCH v2] net/i40e: fix out-of-scope variable

From: Alvin Zhang <[email protected]>

Using "key", which points to an out-of-scope variable "rss_key_default".

Coverity issue: 365293

Fixes ef4c16fd9148 ("net/i40e: refactor RSS flow")

---

V2: Update the commit log.

---
 drivers/net/i40e/i40e_hash.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_hash.c index
e07f806..83a9af5 100644

drivers/net/i40e/i40e_hash.c struct i40e_hash_match_pattern { · line 902

Quoted 2 lines
drivers/net/i40e/i40e_hash.c +0 -0
@@ -901,10 +901,12 @@ struct i40e_hash_match_pattern {
 			PMD_DRV_LOG(WARNING,
 				    "RSS key length invalid, must be %u bytes, now set key

to

Quoted 9 lines
drivers/net/i40e/i40e_hash.c +4 -1
 default",
 				    (uint32_t)sizeof(rss_conf->key));
-		key = (const uint8_t *)rss_key_default;
+
+		memcpy(rss_conf->key, rss_key_default, sizeof(rss_conf->key));
+	} else {
+		memcpy(rss_conf->key, key, sizeof(rss_conf->key));
 	}
 
Quoted 7 lines
Quoted 5 lines
drivers/net/i40e/i40e_hash.c +0 -2
-	memcpy(rss_conf->key, key, sizeof(rss_conf->key));
 	rss_conf->conf.key = rss_conf->key;
 	rss_conf->conf.key_len = sizeof(rss_conf->key);  }
--

1.8.3.1

Applied to dpdk-next-net-intel.

Thanks
Qi