From 52a6478257b26b0eada505d815790c83280be27a Mon Sep 17 00:00:00 2001 From: Alvin Zhang Date: Fri, 15 Jan 2021 16:34:11 +0800 Subject: [PATCH] net/i40e: fix out of scope variable Using "key", which points to an out-of-scope variable "rss_key_default". Coverity issue: 365293 Fixes: ef4c16fd9148 ("net/i40e: refactor RSS flow") Signed-off-by: Alvin Zhang Acked-by: Beilei Xing --- drivers/net/i40e/i40e_hash.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/i40e/i40e_hash.c b/drivers/net/i40e/i40e_hash.c index ae861ab4ff..9271797a77 100644 --- a/drivers/net/i40e/i40e_hash.c +++ b/drivers/net/i40e/i40e_hash.c @@ -903,10 +903,12 @@ i40e_hash_parse_key(const struct rte_flow_action_rss *rss_act, 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); } -- 2.20.1