From patchwork Wed Nov 4 01:24:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yunjian Wang X-Patchwork-Id: 83627 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1B099A04E7; Wed, 4 Nov 2020 02:25:05 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0643BBE43; Wed, 4 Nov 2020 02:25:03 +0100 (CET) Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) by dpdk.org (Postfix) with ESMTP id B387ABBB4 for ; Wed, 4 Nov 2020 02:24:59 +0100 (CET) Received: from DGGEMS401-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CQpq86TCxzkdRX; Wed, 4 Nov 2020 09:24:52 +0800 (CST) Received: from localhost (10.174.187.156) by DGGEMS401-HUB.china.huawei.com (10.3.19.201) with Microsoft SMTP Server id 14.3.487.0; Wed, 4 Nov 2020 09:24:50 +0800 From: wangyunjian To: CC: , , , , , Yunjian Wang Date: Wed, 4 Nov 2020 09:24:36 +0800 Message-ID: <1604453076-34392-1-git-send-email-wangyunjian@huawei.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [10.174.187.156] X-CFilter-Loop: Reflected Subject: [dpdk-dev] [PATCH v2] ethdev: fix check of rx configure 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" From: Yunjian Wang Coverity flags that 'rx_conf' variable is used before it's checked for NULL. This patch fixes this issue. Coverity issue: 363570 Fixes: 4ff702b5dfa9 ("ethdev: introduce Rx buffer split") Signed-off-by: Yunjian Wang Reviewed-by: Ferruh Yigit --- v2: fix code styles suggested by Ferruh Yigit --- lib/librte_ethdev/rte_ethdev.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c index b12bb3854d..1ac59a39e3 100644 --- a/lib/librte_ethdev/rte_ethdev.c +++ b/lib/librte_ethdev/rte_ethdev.c @@ -1978,9 +1978,8 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, return -EINVAL; } } else { - const struct rte_eth_rxseg_split *rx_seg = - (const struct rte_eth_rxseg_split *)rx_conf->rx_seg; - uint16_t n_seg = rx_conf->rx_nseg; + const struct rte_eth_rxseg_split *rx_seg; + uint16_t n_seg; /* Extended multi-segment configuration check. */ if (rx_conf == NULL || rx_conf->rx_seg == NULL || rx_conf->rx_nseg == 0) { @@ -1988,6 +1987,10 @@ rte_eth_rx_queue_setup(uint16_t port_id, uint16_t rx_queue_id, "Memory pool is null and no extended configuration provided\n"); return -EINVAL; } + + rx_seg = (const struct rte_eth_rxseg_split *)rx_conf->rx_seg; + n_seg = rx_conf->rx_nseg; + if (rx_conf->offloads & RTE_ETH_RX_OFFLOAD_BUFFER_SPLIT) { ret = rte_eth_rx_queue_check_split(rx_seg, n_seg, &mbp_buf_size,