crypto/cnxk: fix condition check

Message ID 20220609092731.131856-1-vfialko@marvell.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series crypto/cnxk: fix condition check |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-abi-testing success Testing PASS

Commit Message

Volodymyr Fialko June 9, 2022, 9:27 a.m. UTC
  The value of ec_mdata cannot be NULL, instead check that value of
private_data_offset was set.

       
Fixes: c3a498c01121 ("crypto/cnxk: add event metadata set operation")
Coverity issue: 378861
Coverity issue: 378865

Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
---
 drivers/crypto/cnxk/cn10k_cryptodev_ops.c | 4 ++--
 drivers/crypto/cnxk/cn9k_cryptodev_ops.c  | 4 ++--
 2 files changed, 4 insertions(+), 4 deletions(-)
  

Comments

Anoob Joseph June 9, 2022, 10:31 a.m. UTC | #1
> Subject: [PATCH] crypto/cnxk: fix condition check
> 
> The value of ec_mdata cannot be NULL, instead check that value of
> private_data_offset was set.
> 
> 
> Fixes: c3a498c01121 ("crypto/cnxk: add event metadata set operation")
> Coverity issue: 378861 Coverity issue: 378865
> 
> Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>

Acked-by: Anoob Joseph <anoobj@marvell.com>
  
Akhil Goyal June 15, 2022, 3:45 p.m. UTC | #2
> 
> > Subject: [PATCH] crypto/cnxk: fix condition check
> >
> > The value of ec_mdata cannot be NULL, instead check that value of
> > private_data_offset was set.
> >
> >
> > Fixes: c3a498c01121 ("crypto/cnxk: add event metadata set operation")
> > Coverity issue: 378861 Coverity issue: 378865
> >
> > Signed-off-by: Volodymyr Fialko <vfialko@marvell.com>
> 
> Acked-by: Anoob Joseph <anoobj@marvell.com>

Applied to dpdk-next-crypto

Thanks.
  

Patch

diff --git a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
index c811504f93..f4aaa273c1 100644
--- a/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn10k_cryptodev_ops.c
@@ -363,10 +363,10 @@  cn10k_ca_meta_info_extract(struct rte_crypto_op *op,
 			uint8_t cdev_id;
 			uint16_t qp_id;
 
+			if (unlikely(op->private_data_offset == 0))
+				return -EINVAL;
 			ec_mdata = (union rte_event_crypto_metadata *)
 				((uint8_t *)op + op->private_data_offset);
-			if (!ec_mdata)
-				return -EINVAL;
 			rsp_info = &ec_mdata->response_info;
 			cdev_id = ec_mdata->request_info.cdev_id;
 			qp_id = ec_mdata->request_info.queue_pair_id;
diff --git a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
index 10e7bb6e52..d9d41f9dab 100644
--- a/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
+++ b/drivers/crypto/cnxk/cn9k_cryptodev_ops.c
@@ -419,10 +419,10 @@  cn9k_ca_meta_info_extract(struct rte_crypto_op *op,
 			uint8_t cdev_id;
 			uint16_t qp_id;
 
+			if (unlikely(op->private_data_offset == 0))
+				return -EINVAL;
 			ec_mdata = (union rte_event_crypto_metadata *)
 				((uint8_t *)op + op->private_data_offset);
-			if (!ec_mdata)
-				return -EINVAL;
 			rsp_info = &ec_mdata->response_info;
 			cdev_id = ec_mdata->request_info.cdev_id;
 			qp_id = ec_mdata->request_info.queue_pair_id;