DPDK patches and discussions
 help / color / mirror / Atom feed
From: wangyunjian <wangyunjian@huawei.com>
To: <dev@dpdk.org>
Cc: <thomas@monjalon.net>, <ferruh.yigit@intel.com>,
	<andrew.rybchenko@oktetlabs.ru>, <jerry.lilijun@huawei.com>,
	<xudingke@huawei.com>, Yunjian Wang <wangyunjian@huawei.com>
Subject: [dpdk-dev]  [PATCH v2] ethdev: fix check of rx configure
Date: Wed, 4 Nov 2020 09:24:36 +0800	[thread overview]
Message-ID: <1604453076-34392-1-git-send-email-wangyunjian@huawei.com> (raw)
In-Reply-To: <e103e69b3dee3ada2506816b1cf6e42dbffc72d1.1604409065.git.wangyunjian@huawei.com>

From: Yunjian Wang <wangyunjian@huawei.com>

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 <wangyunjian@huawei.com>
---
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,
-- 
2.18.1


  parent reply	other threads:[~2020-11-04  1:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-11-03 13:31 [dpdk-dev] [PATCH] " wangyunjian
2020-11-03 13:58 ` Ferruh Yigit
2020-11-04  1:15   ` wangyunjian
2020-11-04  1:24 ` wangyunjian [this message]
2020-11-04 11:11   ` [dpdk-dev] [PATCH v2] " Ferruh Yigit
2020-11-04 11:22     ` Ferruh Yigit

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=1604453076-34392-1-git-send-email-wangyunjian@huawei.com \
    --to=wangyunjian@huawei.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=jerry.lilijun@huawei.com \
    --cc=thomas@monjalon.net \
    --cc=xudingke@huawei.com \
    /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).