diff mbox series

[v2] net/i40e: fix out-of-scope variable

Message ID 20210115083411.9324-1-alvinx.zhang@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Qi Zhang
Headers show
Series [v2] net/i40e: fix out-of-scope variable | expand

Checks

Context Check Description
ci/iol-testing warning Testing issues
ci/iol-abi-testing success Testing PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-mellanox-Functional success Functional Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/intel-Testing success Testing PASS
ci/Intel-compilation success Compilation OK
ci/checkpatch success coding style OK

Commit Message

Alvin Zhang Jan. 15, 2021, 8:34 a.m. UTC
From: Alvin Zhang <alvinx.zhang@intel.com>

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>
---

V2: Update the commit log.
---
 drivers/net/i40e/i40e_hash.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Xing, Beilei Jan. 18, 2021, 8:27 a.m. UTC | #1
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Zhang,Alvin
> Sent: Friday, January 15, 2021 4:34 PM
> To: Guo, Jia <jia.guo@intel.com>; Xie, WeiX <weix.xie@intel.com>
> Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>
> Subject: [dpdk-dev] [PATCH v2] net/i40e: fix out-of-scope variable
> 
> From: Alvin Zhang <alvinx.zhang@intel.com>
> 
> 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>
> ---
> 
> 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);  }
> --
> 1.8.3.1

Acked-by: Beilei Xing <beilei.xing@intel.com>
Zhang, Qi Z Jan. 19, 2021, 3:47 a.m. UTC | #2
> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Xing, Beilei
> Sent: Monday, January 18, 2021 4:27 PM
> To: Zhang, AlvinX <alvinx.zhang@intel.com>; Guo, Jia <jia.guo@intel.com>; Xie,
> WeiX <weix.xie@intel.com>
> Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>
> Subject: Re: [dpdk-dev] [PATCH v2] net/i40e: fix out-of-scope variable
> 
> 
> 
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Zhang,Alvin
> > Sent: Friday, January 15, 2021 4:34 PM
> > To: Guo, Jia <jia.guo@intel.com>; Xie, WeiX <weix.xie@intel.com>
> > Cc: dev@dpdk.org; Zhang, AlvinX <alvinx.zhang@intel.com>
> > Subject: [dpdk-dev] [PATCH v2] net/i40e: fix out-of-scope variable
> >
> > From: Alvin Zhang <alvinx.zhang@intel.com>
> >
> > 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>
> > ---
> >
> > 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);  }
> > --
> > 1.8.3.1
> 
> Acked-by: Beilei Xing <beilei.xing@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
diff mbox series

Patch

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);
 }