From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1DB55A0471 for ; Mon, 15 Jul 2019 05:19:56 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 577231B965; Mon, 15 Jul 2019 05:19:50 +0200 (CEST) Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id CC7502BBE; Mon, 15 Jul 2019 05:19:44 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 14 Jul 2019 20:19:43 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,492,1557212400"; d="scan'208";a="168836274" Received: from npg-dpdk-zhangxiao.sh.intel.com ([10.67.110.190]) by fmsmga007.fm.intel.com with ESMTP; 14 Jul 2019 20:19:41 -0700 From: Xiao Zhang To: dev@dpdk.org Cc: qi.z.zhang@intel.com, xiao.w.wang@intel.com, beilei.xing@intel.com, wenzhuo.lu@intel.com, qiming.yang@intel.com, Xiao Zhang , stable@dpdk.org Date: Mon, 15 Jul 2019 20:15:37 +0800 Message-Id: <1563192937-5825-1-git-send-email-xiao.zhang@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [v2] drivers/net: fix dereference after null check coverity 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" This patch tries to fix the coverity issues of dereference after null check. The addresses of receive queue start segment for ice, avf, i40e, fm10k and ixgb were not checked before use. Add check to avoid coverity issues. Coverity issue: 343452 Coverity issue: 343407 Fixes: c68a52b8 ("net/ice: support vector SSE in Rx") Coverity issue: 343447 Fixes: 319c421f ("net/avf: enable SSE Rx Tx") Coverity issue: 343422 Coverity issue: 343403 Fixes: ca74903b ("net/i40e: extract non-x86 specific code from vector driver") Coverity issue: 343416 Fixes: fe65e1e1 ("fm10k: add vector scatter Rx") Coverity issue: 13245 Fixes: 8a44c15a ("net/ixgbe: extract non-x86 specific code from vector driver") Cc: stable@dpdk.org Signed-off-by: Xiao Zhang --- v2 changes: * update commit log with fixes information. drivers/net/fm10k/fm10k_rxtx_vec.c | 3 +++ drivers/net/i40e/i40e_rxtx_vec_common.h | 3 +++ drivers/net/iavf/iavf_rxtx_vec_common.h | 3 +++ drivers/net/ice/ice_rxtx_vec_common.h | 3 +++ drivers/net/ixgbe/ixgbe_rxtx_vec_common.h | 3 +++ 5 files changed, 15 insertions(+) diff --git a/drivers/net/fm10k/fm10k_rxtx_vec.c b/drivers/net/fm10k/fm10k_rxtx_vec.c index 788e248..cb840de 100644 --- a/drivers/net/fm10k/fm10k_rxtx_vec.c +++ b/drivers/net/fm10k/fm10k_rxtx_vec.c @@ -602,6 +602,9 @@ fm10k_reassemble_packets(struct fm10k_rx_queue *rxq, struct rte_mbuf *end = rxq->pkt_last_seg; unsigned pkt_idx, buf_idx; + if (!start) + return 0; + for (buf_idx = 0, pkt_idx = 0; buf_idx < nb_bufs; buf_idx++) { if (end != NULL) { /* processing a split packet */ diff --git a/drivers/net/i40e/i40e_rxtx_vec_common.h b/drivers/net/i40e/i40e_rxtx_vec_common.h index 0e6ffa0..1351e41 100644 --- a/drivers/net/i40e/i40e_rxtx_vec_common.h +++ b/drivers/net/i40e/i40e_rxtx_vec_common.h @@ -20,6 +20,9 @@ reassemble_packets(struct i40e_rx_queue *rxq, struct rte_mbuf **rx_bufs, struct rte_mbuf *end = rxq->pkt_last_seg; unsigned pkt_idx, buf_idx; + if (!start) + return 0; + for (buf_idx = 0, pkt_idx = 0; buf_idx < nb_bufs; buf_idx++) { if (end != NULL) { /* processing a split packet */ diff --git a/drivers/net/iavf/iavf_rxtx_vec_common.h b/drivers/net/iavf/iavf_rxtx_vec_common.h index db509d7..ac3d62a 100644 --- a/drivers/net/iavf/iavf_rxtx_vec_common.h +++ b/drivers/net/iavf/iavf_rxtx_vec_common.h @@ -20,6 +20,9 @@ reassemble_packets(struct iavf_rx_queue *rxq, struct rte_mbuf **rx_bufs, struct rte_mbuf *end = rxq->pkt_last_seg; unsigned int pkt_idx, buf_idx; + if (!start) + return 0; + for (buf_idx = 0, pkt_idx = 0; buf_idx < nb_bufs; buf_idx++) { if (end) { /* processing a split packet */ diff --git a/drivers/net/ice/ice_rxtx_vec_common.h b/drivers/net/ice/ice_rxtx_vec_common.h index c5f0d56..11da521 100644 --- a/drivers/net/ice/ice_rxtx_vec_common.h +++ b/drivers/net/ice/ice_rxtx_vec_common.h @@ -16,6 +16,9 @@ ice_rx_reassemble_packets(struct ice_rx_queue *rxq, struct rte_mbuf **rx_bufs, struct rte_mbuf *end = rxq->pkt_last_seg; unsigned int pkt_idx, buf_idx; + if (!start) + return 0; + for (buf_idx = 0, pkt_idx = 0; buf_idx < nb_bufs; buf_idx++) { if (end) { /* processing a split packet */ diff --git a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h index a97c271..a95cc0a 100644 --- a/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h +++ b/drivers/net/ixgbe/ixgbe_rxtx_vec_common.h @@ -19,6 +19,9 @@ reassemble_packets(struct ixgbe_rx_queue *rxq, struct rte_mbuf **rx_bufs, struct rte_mbuf *end = rxq->pkt_last_seg; unsigned int pkt_idx, buf_idx; + if (!start) + return 0; + for (buf_idx = 0, pkt_idx = 0; buf_idx < nb_bufs; buf_idx++) { if (end != NULL) { /* processing a split packet */ -- 2.7.4