From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by dpdk.space (Postfix) with ESMTP id 915A4A05D3 for ; Thu, 25 Apr 2019 11:11:10 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 73A831B564; Thu, 25 Apr 2019 11:11:09 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 30F171B562 for ; Thu, 25 Apr 2019 11:11:07 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 25 Apr 2019 02:11:07 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,393,1549958400"; d="scan'208";a="167790716" Received: from unknown (HELO localhost.localdomain) ([10.224.122.195]) by fmsmga001.fm.intel.com with ESMTP; 25 Apr 2019 02:11:05 -0700 From: Abhinandan Gujjar To: jerin.jacob@caviumnetworks.com, dev@dpdk.org Cc: narender.vangati@intel.com, abhinandan.gujjar@intel.com, john.mcnamara@intel.com Date: Wed, 24 Apr 2019 22:04:38 +0530 Message-Id: <1556123678-80860-1-git-send-email-abhinandan.gujjar@intel.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] eventdev: fix control flow issues X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Content-Type: text/plain; charset="UTF-8" Message-ID: <20190424163438.HFz1NqhwX7NCjW2T4Hg5kkZZAM2UzmB4UN5PZw7LTuE@z> This patch fixes null pointer dereference and control flow issues reported in event crypto adapter by coverity Coverity issue: 279439 Dereference null return value Coverity issue: 279446 Logically dead code Coverity issue: 279450 Logically dead code Coverity issue: 279462 Logically dead code Fixes: 7901eac3409 ("eventdev: add crypto adapter implementation") Signed-off-by: Abhinandan Gujjar --- lib/librte_eventdev/rte_event_crypto_adapter.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/lib/librte_eventdev/rte_event_crypto_adapter.c b/lib/librte_eventdev/rte_event_crypto_adapter.c index 11b28ca..5faf3c9 100644 --- a/lib/librte_eventdev/rte_event_crypto_adapter.c +++ b/lib/librte_eventdev/rte_event_crypto_adapter.c @@ -159,6 +159,9 @@ struct crypto_queue_pair_info { struct rte_event_port_conf *port_conf = arg; struct rte_event_crypto_adapter *adapter = eca_id_to_adapter(id); + if (adapter == NULL) + return -EINVAL; + dev = &rte_eventdevs[adapter->eventdev_id]; dev_conf = dev->data->dev_conf; @@ -353,7 +356,7 @@ struct crypto_queue_pair_info { cdev_id = m_data->request_info.cdev_id; qp_id = m_data->request_info.queue_pair_id; qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id]; - if (qp_info == NULL) { + if (!qp_info->qp_enabled) { rte_pktmbuf_free(crypto_op->sym->m_src); rte_crypto_op_free(crypto_op); continue; @@ -369,7 +372,7 @@ struct crypto_queue_pair_info { cdev_id = m_data->request_info.cdev_id; qp_id = m_data->request_info.queue_pair_id; qp_info = &adapter->cdevs[cdev_id].qpairs[qp_id]; - if (qp_info == NULL) { + if (!qp_info->qp_enabled) { rte_pktmbuf_free(crypto_op->sym->m_src); rte_crypto_op_free(crypto_op); continue; @@ -427,10 +430,9 @@ struct crypto_queue_pair_info { ret = 0; for (cdev_id = 0; cdev_id < num_cdev; cdev_id++) { curr_dev = &adapter->cdevs[cdev_id]; - if (curr_dev == NULL) - continue; dev = curr_dev->dev; - + if (dev == NULL) + continue; for (qp = 0; qp < dev->data->nb_queue_pairs; qp++) { curr_queue = &curr_dev->qpairs[qp]; @@ -579,9 +581,9 @@ struct crypto_queue_pair_info { for (cdev_id = adapter->next_cdev_id; cdev_id < num_cdev; cdev_id++) { curr_dev = &adapter->cdevs[cdev_id]; - if (curr_dev == NULL) - continue; dev = curr_dev->dev; + if (dev == NULL) + continue; dev_qps = dev->data->nb_queue_pairs; for (qp = curr_dev->next_queue_pair_id; -- 1.9.1