DPDK patches and discussions
 help / color / mirror / Atom feed
From: Volodymyr Fialko <vfialko@marvell.com>
To: <dev@dpdk.org>, Ankur Dwivedi <adwivedi@marvell.com>,
	Anoob Joseph <anoobj@marvell.com>,
	Tejasree Kondoj <ktejasree@marvell.com>,
	"Abhinandan Gujjar" <Abhinandan.gujjar@intel.com>,
	Akhil Goyal <gakhil@marvell.com>,
	Volodymyr Fialko <vfialko@marvell.com>,
	Fan Zhang <roy.fan.zhang@intel.com>
Cc: <jerinj@marvell.com>
Subject: [PATCH] crypto/cnxk: fix condition check
Date: Thu, 9 Jun 2022 11:27:31 +0200	[thread overview]
Message-ID: <20220609092731.131856-1-vfialko@marvell.com> (raw)

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

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


             reply	other threads:[~2022-06-09  9:28 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-09  9:27 Volodymyr Fialko [this message]
2022-06-09 10:31 ` Anoob Joseph
2022-06-15 15:45   ` Akhil Goyal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220609092731.131856-1-vfialko@marvell.com \
    --to=vfialko@marvell.com \
    --cc=Abhinandan.gujjar@intel.com \
    --cc=adwivedi@marvell.com \
    --cc=anoobj@marvell.com \
    --cc=dev@dpdk.org \
    --cc=gakhil@marvell.com \
    --cc=jerinj@marvell.com \
    --cc=ktejasree@marvell.com \
    --cc=roy.fan.zhang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).