DPDK patches and discussions
 help / color / mirror / Atom feed
From: Helin Zhang <helin.zhang@intel.com>
To: dev@dpdk.org
Cc: Helin Zhang <helin.zhang@intel.com>
Subject: [dpdk-dev] [PATCH v2 1/2] i40e: fix problematic dereference
Date: Sun, 26 Jun 2016 23:46:17 +0800	[thread overview]
Message-ID: <1466955978-24386-2-git-send-email-helin.zhang@intel.com> (raw)
In-Reply-To: <1466955978-24386-1-git-send-email-helin.zhang@intel.com>

It fixes the issue reported by Coverity of 'Dereference before
null check', by deleting null checks as they are not necessary
at all, or move null checks before where uses it.

Coverity ID 119267: Dereference before null check.
Coverity ID 13301: Dereference before null check.
Coverity ID 13294: Dereference before null check.
Coverity ID 13299: Dereference before null check.
Coverity ID 13298: Dereference before null check.

Fixes: 8e109464c022 ("i40e: allow vector Rx and Tx usage")
Fixes: a778a1fa2e4e ("i40e: set up and initialize flow director")
Fixes: a778a1fa2e4e ("i40e: set up and initialize flow director")
Fixes: 4861cde46116 ("i40e: new poll mode driver")

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
---
 drivers/net/i40e/i40e_pf.c   |  5 +++--
 drivers/net/i40e/i40e_rxtx.c | 12 ++++++++----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c
index 5afd61a..1bd599b 100644
--- a/drivers/net/i40e/i40e_pf.c
+++ b/drivers/net/i40e/i40e_pf.c
@@ -123,7 +123,7 @@ int
 i40e_pf_host_vf_reset(struct i40e_pf_vf *vf, bool do_hw_reset)
 {
 	uint32_t val, i;
-	struct i40e_hw *hw = I40E_PF_TO_HW(vf->pf);
+	struct i40e_hw *hw;
 	uint16_t vf_id, abs_vf_id, vf_msix_num;
 	int ret;
 	struct i40e_virtchnl_queue_select qsel;
@@ -131,6 +131,7 @@ i40e_pf_host_vf_reset(struct i40e_pf_vf *vf, bool do_hw_reset)
 	if (vf == NULL)
 		return -EINVAL;
 
+	hw = I40E_PF_TO_HW(vf->pf);
 	vf_id = vf->vf_idx;
 	abs_vf_id = vf_id + hw->func_caps.vf_base_id;
 
@@ -913,7 +914,7 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev,
 	/* AdminQ will pass absolute VF id, transfer to internal vf id */
 	uint16_t vf_id = abs_vf_id - hw->func_caps.vf_base_id;
 
-	if (!dev || vf_id > pf->vf_num - 1 || !pf->vfs) {
+	if (vf_id > pf->vf_num - 1 || !pf->vfs) {
 		PMD_DRV_LOG(ERR, "invalid argument");
 		return;
 	}
diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c
index 049a813..7bb0aa9 100644
--- a/drivers/net/i40e/i40e_rxtx.c
+++ b/drivers/net/i40e/i40e_rxtx.c
@@ -2614,8 +2614,8 @@ i40e_rx_queue_release_mbufs(struct i40e_rx_queue *rxq)
 		return;
 	}
 
-	if (!rxq || !rxq->sw_ring) {
-		PMD_DRV_LOG(DEBUG, "Pointer to rxq or sw_ring is NULL");
+	if (!rxq->sw_ring) {
+		PMD_DRV_LOG(DEBUG, "Pointer to sw_ring is NULL");
 		return;
 	}
 
@@ -3002,13 +3002,15 @@ i40e_fdir_setup_tx_resources(struct i40e_pf *pf)
 	struct i40e_tx_queue *txq;
 	const struct rte_memzone *tz = NULL;
 	uint32_t ring_size;
-	struct rte_eth_dev *dev = pf->adapter->eth_dev;
+	struct rte_eth_dev *dev;
 
 	if (!pf) {
 		PMD_DRV_LOG(ERR, "PF is not available");
 		return I40E_ERR_BAD_PTR;
 	}
 
+	dev = pf->adapter->eth_dev;
+
 	/* Allocate the TX queue data structure. */
 	txq = rte_zmalloc_socket("i40e fdir tx queue",
 				  sizeof(struct i40e_tx_queue),
@@ -3056,13 +3058,15 @@ i40e_fdir_setup_rx_resources(struct i40e_pf *pf)
 	struct i40e_rx_queue *rxq;
 	const struct rte_memzone *rz = NULL;
 	uint32_t ring_size;
-	struct rte_eth_dev *dev = pf->adapter->eth_dev;
+	struct rte_eth_dev *dev;
 
 	if (!pf) {
 		PMD_DRV_LOG(ERR, "PF is not available");
 		return I40E_ERR_BAD_PTR;
 	}
 
+	dev = pf->adapter->eth_dev;
+
 	/* Allocate the RX queue data structure. */
 	rxq = rte_zmalloc_socket("i40e fdir rx queue",
 				  sizeof(struct i40e_rx_queue),
-- 
2.5.0

  reply	other threads:[~2016-06-26 15:46 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-21  3:42 [dpdk-dev] [PATCH 0/6] fix i40e " Helin Zhang
2016-04-21  3:42 ` [dpdk-dev] [PATCH 1/6] i40e: fix " Helin Zhang
2016-04-21 16:10   ` Stephen Hemminger
2016-04-22  1:04     ` Zhang, Helin
2016-04-21  3:42 ` [dpdk-dev] [PATCH 2/6] " Helin Zhang
2016-04-21  3:42 ` [dpdk-dev] [PATCH 3/6] " Helin Zhang
2016-04-21  3:42 ` [dpdk-dev] [PATCH 4/6] " Helin Zhang
2016-04-21  3:42 ` [dpdk-dev] [PATCH 5/6] " Helin Zhang
2016-04-21  3:42 ` [dpdk-dev] [PATCH 6/6] " Helin Zhang
2016-04-21 10:06 ` [dpdk-dev] [PATCH 0/6] fix i40e " Thomas Monjalon
2016-04-21 12:49   ` Zhang, Helin
2016-04-21 12:51     ` Thomas Monjalon
2016-04-21 11:01 ` Bruce Richardson
2016-04-21 12:50   ` Zhang, Helin
2016-04-25  5:44 ` [dpdk-dev] [PATCH v2] i40e: fix " Helin Zhang
2016-04-25  9:41   ` Bruce Richardson
2016-04-28  3:17   ` [dpdk-dev] [PATCH v3 0/2] fix Coverity reported issues Helin Zhang
2016-04-28  3:17   ` [dpdk-dev] [PATCH v3 1/2] i40e: fix problematic dereference Helin Zhang
2016-04-28  3:17   ` [dpdk-dev] [PATCH v3 2/2] i40e: fix missing break in switch Helin Zhang
2016-06-26 15:46 ` [dpdk-dev] [PATCH v2 0/2] fix coverity issues Helin Zhang
2016-06-26 15:46   ` Helin Zhang [this message]
2016-06-26 20:04     ` [dpdk-dev] [PATCH v2 1/2] i40e: fix problematic dereference Mcnamara, John
2016-06-26 15:46   ` [dpdk-dev] [PATCH v2 2/2] i40e: fix missing break in switch Helin Zhang
2016-06-26 20:04     ` Mcnamara, John
2016-06-28 12:01   ` [dpdk-dev] [PATCH v2 0/2] fix coverity issues Bruce Richardson

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=1466955978-24386-2-git-send-email-helin.zhang@intel.com \
    --to=helin.zhang@intel.com \
    --cc=dev@dpdk.org \
    /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).