From patchwork Fri Jan 15 08:34:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alvin Zhang X-Patchwork-Id: 86662 X-Patchwork-Delegate: qi.z.zhang@intel.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id A094BA0A02; Fri, 15 Jan 2021 09:34:27 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5631A140DD4; Fri, 15 Jan 2021 09:34:27 +0100 (CET) Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by mails.dpdk.org (Postfix) with ESMTP id E488A140DCD for ; Fri, 15 Jan 2021 09:34:25 +0100 (CET) IronPort-SDR: 3t3ih6nuFhayQM4iql19kTOuYns83HILflpfXcKzqP+i08scg+HphdCevcd/oTIG6Bg3Ceb0Ny yu4ATqYZP4MQ== X-IronPort-AV: E=McAfee;i="6000,8403,9864"; a="165604631" X-IronPort-AV: E=Sophos;i="5.79,348,1602572400"; d="scan'208";a="165604631" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2021 00:34:20 -0800 IronPort-SDR: zh0nHZnWHyBD3A7D+ds7g1SZVW3Bf8bLuZgEpAPtyJhF/gRcgcKIsChqUtV0G/4gcnp3ea4MGf 7eByIXm9eEjg== X-IronPort-AV: E=Sophos;i="5.79,348,1602572400"; d="scan'208";a="401219068" Received: from shwdenpg235.ccr.corp.intel.com ([10.240.182.60]) by fmsmga002-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 15 Jan 2021 00:34:16 -0800 From: "Zhang,Alvin" To: jia.guo@intel.com, WeiX.Xie@intel.com Cc: dev@dpdk.org, Alvin Zhang Date: Fri, 15 Jan 2021 16:34:11 +0800 Message-Id: <20210115083411.9324-1-alvinx.zhang@intel.com> X-Mailer: git-send-email 2.21.0.windows.1 In-Reply-To: <20210114065248.17160-1-alvinx.zhang@intel.com> References: <20210114065248.17160-1-alvinx.zhang@intel.com> MIME-Version: 1.0 Subject: [dpdk-dev] [PATCH v2] net/i40e: fix out-of-scope variable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Alvin Zhang 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 --- V2: Update the commit log. --- 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 e07f806..83a9af5 100644 --- a/drivers/net/i40e/i40e_hash.c +++ b/drivers/net/i40e/i40e_hash.c @@ -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); }