examples/fips_validation: fix logically dead code

Message ID 20190515154121.75459-1-roy.fan.zhang@intel.com
State Accepted
Delegated to: akhil goyal
Headers show
Series
  • examples/fips_validation: fix logically dead code
Related show

Checks

Context Check Description
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS
ci/checkpatch success coding style OK

Commit Message

Zhang, Roy Fan May 15, 2019, 3:41 p.m.
Coverity issue: 336866
Coverity issue: 336841
Coverity issue: 336838
Fixes: 41d561cbdd24 ("examples/fips_validation: add power on self test")

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 examples/fips_validation/fips_dev_self_test.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

Comments

Kovacevic, Marko June 17, 2019, 11:10 a.m. | #1
> Subject: [dpdk-dev] [PATCH] examples/fips_validation: fix logically dead
> code
> 
> Coverity issue: 336866
> Coverity issue: 336841
> Coverity issue: 336838
> Fixes: 41d561cbdd24 ("examples/fips_validation: add power on self test")
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> ---
>  examples/fips_validation/fips_dev_self_test.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
> 
> diff --git a/examples/fips_validation/fips_dev_self_test.c
> b/examples/fips_validation/fips_dev_self_test.c
> index df1c0e82e..444bbaa79 100644
> --- a/examples/fips_validation/fips_dev_self_test.c
> +++ b/examples/fips_validation/fips_dev_self_test.c
> @@ -1333,6 +1333,9 @@ check_cipher_result(struct rte_crypto_op *op,
>  	uint32_t len, src_len;
>  	int ret;
> 
> +	if (!mbuf)
> +		return -1;
> +
>  	if (dir == self_test_dir_enc_auth_gen) {
>  		src = vec->output.data;
>  		src_len = vec->output.len;
> @@ -1342,7 +1345,7 @@ check_cipher_result(struct rte_crypto_op *op,
>  	}
> 
>  	GET_MBUF_DATA(data, len, mbuf);
> -	if (!data && !len)
> +	if (!len)
>  		return -1;
> 
>  	ret = memcmp(data, src, src_len);
> @@ -1362,8 +1365,11 @@ check_auth_result(struct rte_crypto_op *op,
>  	uint32_t len;
>  	int ret;
> 
> +	if (mbuf == NULL)
> +		return -1;
> +
>  	GET_MBUF_DATA(data, len, mbuf);
> -	if (!data && !len)
> +	if (!len)
>  		return -1;
> 
>  	if (dir == self_test_dir_enc_auth_gen) { @@ -1387,6 +1393,9 @@
> check_aead_result(struct rte_crypto_op *op,
>  	uint32_t len, src_len;
>  	int ret;
> 
> +	if (!mbuf)
> +		return -1;
> +
>  	if (op->sym->aead.aad.data)
>  		rte_free(op->sym->aead.aad.data);
> 
> @@ -1399,7 +1408,7 @@ check_aead_result(struct rte_crypto_op *op,
>  	}
> 
>  	GET_MBUF_DATA(data, len, mbuf);
> -	if (!data && !len)
> +	if (!len)
>  		return -1;
> 
>  	ret = memcmp(data, src, src_len);
> --

Acked-by: Marko Kovacevic <marko.kovacevic@intel.com>
Akhil Goyal June 19, 2019, 2:56 p.m. | #2
> >
> > Coverity issue: 336866
> > Coverity issue: 336841
> > Coverity issue: 336838
> > Fixes: 41d561cbdd24 ("examples/fips_validation: add power on self test")
> >
> > Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
> > ---
> 
> Acked-by: Marko Kovacevic <marko.kovacevic@intel.com>
Cc: stable@dpdk.org

Applied to dpdk-next-crypto

Thanks

Patch

diff --git a/examples/fips_validation/fips_dev_self_test.c b/examples/fips_validation/fips_dev_self_test.c
index df1c0e82e..444bbaa79 100644
--- a/examples/fips_validation/fips_dev_self_test.c
+++ b/examples/fips_validation/fips_dev_self_test.c
@@ -1333,6 +1333,9 @@  check_cipher_result(struct rte_crypto_op *op,
 	uint32_t len, src_len;
 	int ret;
 
+	if (!mbuf)
+		return -1;
+
 	if (dir == self_test_dir_enc_auth_gen) {
 		src = vec->output.data;
 		src_len = vec->output.len;
@@ -1342,7 +1345,7 @@  check_cipher_result(struct rte_crypto_op *op,
 	}
 
 	GET_MBUF_DATA(data, len, mbuf);
-	if (!data && !len)
+	if (!len)
 		return -1;
 
 	ret = memcmp(data, src, src_len);
@@ -1362,8 +1365,11 @@  check_auth_result(struct rte_crypto_op *op,
 	uint32_t len;
 	int ret;
 
+	if (mbuf == NULL)
+		return -1;
+
 	GET_MBUF_DATA(data, len, mbuf);
-	if (!data && !len)
+	if (!len)
 		return -1;
 
 	if (dir == self_test_dir_enc_auth_gen) {
@@ -1387,6 +1393,9 @@  check_aead_result(struct rte_crypto_op *op,
 	uint32_t len, src_len;
 	int ret;
 
+	if (!mbuf)
+		return -1;
+
 	if (op->sym->aead.aad.data)
 		rte_free(op->sym->aead.aad.data);
 
@@ -1399,7 +1408,7 @@  check_aead_result(struct rte_crypto_op *op,
 	}
 
 	GET_MBUF_DATA(data, len, mbuf);
-	if (!data && !len)
+	if (!len)
 		return -1;
 
 	ret = memcmp(data, src, src_len);