From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id E1CA92935 for ; Mon, 25 Apr 2016 07:44:18 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 24 Apr 2016 22:44:06 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,531,1455004800"; d="scan'208";a="939432085" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 24 Apr 2016 22:44:05 -0700 Received: from shecgisg005.sh.intel.com (shecgisg005.sh.intel.com [10.239.39.67]) by shvmail01.sh.intel.com with ESMTP id u3P5i4S2032162; Mon, 25 Apr 2016 13:44:04 +0800 Received: from shecgisg005.sh.intel.com (localhost [127.0.0.1]) by shecgisg005.sh.intel.com with ESMTP id u3P5i4dZ001083; Mon, 25 Apr 2016 13:44:04 +0800 Received: (from hzhan75@localhost) by shecgisg005.sh.intel.com with œ id u3P5i4PF001079; Mon, 25 Apr 2016 13:44:04 +0800 From: Helin Zhang To: dev@dpdk.org Cc: Helin Zhang Date: Mon, 25 Apr 2016 13:44:02 +0800 Message-Id: <1461563042-886-1-git-send-email-helin.zhang@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1461210177-29330-1-git-send-email-helin.zhang@intel.com> References: <1461210177-29330-1-git-send-email-helin.zhang@intel.com> Subject: [dpdk-dev] [PATCH v2] i40e: fix problematic dereference X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 25 Apr 2016 05:44:19 -0000 Fix issue reported by Coverity. 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. Coverity ID 13265: Missing break in switch. 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 --- drivers/net/i40e/i40e_pf.c | 7 +++---- drivers/net/i40e/i40e_rxtx.c | 10 +++++++--- 2 files changed, 10 insertions(+), 7 deletions(-) v2: - Combined all the patches into a single one, as suggested. - Remove checking rxq, as it shouldn't be NULL at any time. diff --git a/drivers/net/i40e/i40e_pf.c b/drivers/net/i40e/i40e_pf.c index 5afd61a..1ea7b0a 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; } @@ -999,8 +1000,6 @@ i40e_pf_host_handle_vf_msg(struct rte_eth_dev *dev, /* Don't add command supported below, which will * return an error code. */ - case I40E_VIRTCHNL_OP_FCOE: - PMD_DRV_LOG(ERR, "OP_FCOE received, not supported"); default: PMD_DRV_LOG(ERR, "%u received, not supported", opcode); i40e_pf_host_send_msg_to_vf(vf, opcode, I40E_ERR_PARAM, diff --git a/drivers/net/i40e/i40e_rxtx.c b/drivers/net/i40e/i40e_rxtx.c index 4d35d83..f9e17fd 100644 --- a/drivers/net/i40e/i40e_rxtx.c +++ b/drivers/net/i40e/i40e_rxtx.c @@ -2598,7 +2598,7 @@ i40e_rx_queue_release_mbufs(struct i40e_rx_queue *rxq) return; } - if (!rxq || !rxq->sw_ring) { + if (!rxq->sw_ring) { PMD_DRV_LOG(DEBUG, "Pointer to rxq or sw_ring is NULL"); return; } @@ -2981,13 +2981,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), @@ -3035,13 +3037,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