net/i40e: fix out of scope variable
authorAlvin Zhang <alvinx.zhang@intel.com>
Fri, 15 Jan 2021 08:34:11 +0000 (16:34 +0800)
committerFerruh Yigit <ferruh.yigit@intel.com>
Tue, 19 Jan 2021 12:49:41 +0000 (13:49 +0100)
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 <alvinx.zhang@intel.com>
Acked-by: Beilei Xing <beilei.xing@intel.com>
drivers/net/i40e/i40e_hash.c

index ae861ab..9271797 100644 (file)
@@ -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);
 }