DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev]  [PATCH] ethdev: fix check of rx configure
@ 2020-11-03 13:31 wangyunjian
  2020-11-03 13:58 ` Ferruh Yigit
  2020-11-04  1:24 ` [dpdk-dev] [PATCH v2] " wangyunjian
  0 siblings, 2 replies; 6+ messages in thread
From: wangyunjian @ 2020-11-03 13:31 UTC (permalink / raw)
  To: dev
  Cc: thomas, ferruh.yigit, andrew.rybchenko, jerry.lilijun, xudingke,
	Yunjian Wang

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>
---
 lib/librte_ethdev/rte_ethdev.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
index b12bb3854d..c74502d45e 100644
--- a/lib/librte_ethdev/rte_ethdev.c
+++ b/lib/librte_ethdev/rte_ethdev.c
@@ -1978,16 +1978,17 @@ 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;
-
 		/* Extended multi-segment configuration check. */
 		if (rx_conf == NULL || rx_conf->rx_seg == NULL || rx_conf->rx_nseg == 0) {
 			RTE_ETHDEV_LOG(ERR,
 				       "Memory pool is null and no extended configuration provided\n");
 			return -EINVAL;
 		}
+
+		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;
+
 		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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] ethdev: fix check of rx configure
  2020-11-03 13:31 [dpdk-dev] [PATCH] ethdev: fix check of rx configure wangyunjian
@ 2020-11-03 13:58 ` Ferruh Yigit
  2020-11-04  1:15   ` wangyunjian
  2020-11-04  1:24 ` [dpdk-dev] [PATCH v2] " wangyunjian
  1 sibling, 1 reply; 6+ messages in thread
From: Ferruh Yigit @ 2020-11-03 13:58 UTC (permalink / raw)
  To: wangyunjian, dev; +Cc: thomas, andrew.rybchenko, jerry.lilijun, xudingke

On 11/3/2020 1:31 PM, wangyunjian wrote:
> 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>
> ---
>   lib/librte_ethdev/rte_ethdev.c | 9 +++++----
>   1 file changed, 5 insertions(+), 4 deletions(-)
> 
> diff --git a/lib/librte_ethdev/rte_ethdev.c b/lib/librte_ethdev/rte_ethdev.c
> index b12bb3854d..c74502d45e 100644
> --- a/lib/librte_ethdev/rte_ethdev.c
> +++ b/lib/librte_ethdev/rte_ethdev.c
> @@ -1978,16 +1978,17 @@ 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;
> -
>   		/* Extended multi-segment configuration check. */
>   		if (rx_conf == NULL || rx_conf->rx_seg == NULL || rx_conf->rx_nseg == 0) {
>   			RTE_ETHDEV_LOG(ERR,
>   				       "Memory pool is null and no extended configuration provided\n");
>   			return -EINVAL;
>   		}
> +
> +		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;
> +

Can you please leave the declaration of the variables at the beginning of the 
block, but move the assignment?

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH] ethdev: fix check of rx configure
  2020-11-03 13:58 ` Ferruh Yigit
@ 2020-11-04  1:15   ` wangyunjian
  0 siblings, 0 replies; 6+ messages in thread
From: wangyunjian @ 2020-11-04  1:15 UTC (permalink / raw)
  To: Ferruh Yigit, dev; +Cc: thomas, andrew.rybchenko, Lilijun (Jerry), xudingke

> -----Original Message-----
> From: Ferruh Yigit [mailto:ferruh.yigit@intel.com]
> Sent: Tuesday, November 3, 2020 9:58 PM
> To: wangyunjian <wangyunjian@huawei.com>; dev@dpdk.org
> Cc: thomas@monjalon.net; andrew.rybchenko@oktetlabs.ru; Lilijun (Jerry)
> <jerry.lilijun@huawei.com>; xudingke <xudingke@huawei.com>
> Subject: Re: [dpdk-dev] [PATCH] ethdev: fix check of rx configure
> 
> On 11/3/2020 1:31 PM, wangyunjian wrote:
> > 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>
> > ---
> >   lib/librte_ethdev/rte_ethdev.c | 9 +++++----
> >   1 file changed, 5 insertions(+), 4 deletions(-)
> >
> > diff --git a/lib/librte_ethdev/rte_ethdev.c
> > b/lib/librte_ethdev/rte_ethdev.c index b12bb3854d..c74502d45e 100644
> > --- a/lib/librte_ethdev/rte_ethdev.c
> > +++ b/lib/librte_ethdev/rte_ethdev.c
> > @@ -1978,16 +1978,17 @@ 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;
> > -
> >   		/* Extended multi-segment configuration check. */
> >   		if (rx_conf == NULL || rx_conf->rx_seg == NULL ||
> rx_conf->rx_nseg == 0) {
> >   			RTE_ETHDEV_LOG(ERR,
> >   				       "Memory pool is null and no extended
> configuration provided\n");
> >   			return -EINVAL;
> >   		}
> > +
> > +		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;
> > +
> 
> Can you please leave the declaration of the variables at the beginning of the
> block, but move the assignment?

OK, thanks for your suggestion, will include it in next version.

Yunjian

^ permalink raw reply	[flat|nested] 6+ messages in thread

* [dpdk-dev]  [PATCH v2] ethdev: fix check of rx configure
  2020-11-03 13:31 [dpdk-dev] [PATCH] ethdev: fix check of rx configure wangyunjian
  2020-11-03 13:58 ` Ferruh Yigit
@ 2020-11-04  1:24 ` wangyunjian
  2020-11-04 11:11   ` Ferruh Yigit
  1 sibling, 1 reply; 6+ messages in thread
From: wangyunjian @ 2020-11-04  1:24 UTC (permalink / raw)
  To: dev
  Cc: thomas, ferruh.yigit, andrew.rybchenko, jerry.lilijun, xudingke,
	Yunjian Wang

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] ethdev: fix check of rx configure
  2020-11-04  1:24 ` [dpdk-dev] [PATCH v2] " wangyunjian
@ 2020-11-04 11:11   ` Ferruh Yigit
  2020-11-04 11:22     ` Ferruh Yigit
  0 siblings, 1 reply; 6+ messages in thread
From: Ferruh Yigit @ 2020-11-04 11:11 UTC (permalink / raw)
  To: wangyunjian, dev; +Cc: thomas, andrew.rybchenko, jerry.lilijun, xudingke

On 11/4/2020 1:24 AM, wangyunjian wrote:
> 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>
Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [dpdk-dev] [PATCH v2] ethdev: fix check of rx configure
  2020-11-04 11:11   ` Ferruh Yigit
@ 2020-11-04 11:22     ` Ferruh Yigit
  0 siblings, 0 replies; 6+ messages in thread
From: Ferruh Yigit @ 2020-11-04 11:22 UTC (permalink / raw)
  To: wangyunjian, dev; +Cc: thomas, andrew.rybchenko, jerry.lilijun, xudingke

On 11/4/2020 11:11 AM, Ferruh Yigit wrote:
> On 11/4/2020 1:24 AM, wangyunjian wrote:
>> 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>
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>
> 

Applied to dpdk-next-net/main, thanks.

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2020-11-04 11:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-03 13:31 [dpdk-dev] [PATCH] ethdev: fix check of rx configure wangyunjian
2020-11-03 13:58 ` Ferruh Yigit
2020-11-04  1:15   ` wangyunjian
2020-11-04  1:24 ` [dpdk-dev] [PATCH v2] " wangyunjian
2020-11-04 11:11   ` Ferruh Yigit
2020-11-04 11:22     ` Ferruh Yigit

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).