DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] net/ice: fix missed pointer check
@ 2020-11-10  6:45 Wenzhuo Lu
  2020-11-10 10:05 ` Ananyev, Konstantin
  0 siblings, 1 reply; 3+ messages in thread
From: Wenzhuo Lu @ 2020-11-10  6:45 UTC (permalink / raw)
  To: dev; +Cc: Wenzhuo Lu

The return value of rte_mempool_default_cache should be
checked as it can be NULL.

Fixes: a4e480de268e ("net/ice: optimize Tx by using AVX512")

Reported-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
 drivers/net/ice/ice_rxtx_vec_avx512.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ice/ice_rxtx_vec_avx512.c b/drivers/net/ice/ice_rxtx_vec_avx512.c
index e5e7cc1..af6b324 100644
--- a/drivers/net/ice/ice_rxtx_vec_avx512.c
+++ b/drivers/net/ice/ice_rxtx_vec_avx512.c
@@ -781,9 +781,14 @@
 
 	if (txq->offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE && (n & 31) == 0) {
 		struct rte_mempool *mp = txep[0].mbuf->pool;
+		void **cache_objs;
 		struct rte_mempool_cache *cache = rte_mempool_default_cache(mp,
 				rte_lcore_id());
-		void **cache_objs = &cache->objs[cache->len];
+
+		if (!cache || cache->len == 0)
+			goto normal;
+
+		cache_objs = &cache->objs[cache->len];
 
 		if (n > RTE_MEMPOOL_CACHE_MAX_SIZE) {
 			rte_mempool_ops_enqueue_bulk(mp, (void *)txep, n);
@@ -821,6 +826,7 @@
 		goto done;
 	}
 
+normal:
 	m = rte_pktmbuf_prefree_seg(txep[0].mbuf);
 	if (likely(m)) {
 		free[0] = m;
-- 
1.9.3


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

* Re: [dpdk-dev] [PATCH] net/ice: fix missed pointer check
  2020-11-10  6:45 [dpdk-dev] [PATCH] net/ice: fix missed pointer check Wenzhuo Lu
@ 2020-11-10 10:05 ` Ananyev, Konstantin
  2020-11-10 10:16   ` Zhang, Qi Z
  0 siblings, 1 reply; 3+ messages in thread
From: Ananyev, Konstantin @ 2020-11-10 10:05 UTC (permalink / raw)
  To: Lu, Wenzhuo, dev; +Cc: Lu, Wenzhuo



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Wenzhuo Lu
> Sent: Tuesday, November 10, 2020 6:46 AM
> To: dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Subject: [dpdk-dev] [PATCH] net/ice: fix missed pointer check
> 
> The return value of rte_mempool_default_cache should be
> checked as it can be NULL.
> 
> Fixes: a4e480de268e ("net/ice: optimize Tx by using AVX512")
> 
> Reported-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> ---
>  drivers/net/ice/ice_rxtx_vec_avx512.c | 8 +++++++-
>  1 file changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ice/ice_rxtx_vec_avx512.c b/drivers/net/ice/ice_rxtx_vec_avx512.c
> index e5e7cc1..af6b324 100644
> --- a/drivers/net/ice/ice_rxtx_vec_avx512.c
> +++ b/drivers/net/ice/ice_rxtx_vec_avx512.c
> @@ -781,9 +781,14 @@
> 
>  	if (txq->offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE && (n & 31) == 0) {
>  		struct rte_mempool *mp = txep[0].mbuf->pool;
> +		void **cache_objs;
>  		struct rte_mempool_cache *cache = rte_mempool_default_cache(mp,
>  				rte_lcore_id());
> -		void **cache_objs = &cache->objs[cache->len];
> +
> +		if (!cache || cache->len == 0)
> +			goto normal;
> +
> +		cache_objs = &cache->objs[cache->len];
> 
>  		if (n > RTE_MEMPOOL_CACHE_MAX_SIZE) {
>  			rte_mempool_ops_enqueue_bulk(mp, (void *)txep, n);
> @@ -821,6 +826,7 @@
>  		goto done;
>  	}
> 
> +normal:
>  	m = rte_pktmbuf_prefree_seg(txep[0].mbuf);
>  	if (likely(m)) {
>  		free[0] = m;
> --

Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

> 1.9.3


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

* Re: [dpdk-dev] [PATCH] net/ice: fix missed pointer check
  2020-11-10 10:05 ` Ananyev, Konstantin
@ 2020-11-10 10:16   ` Zhang, Qi Z
  0 siblings, 0 replies; 3+ messages in thread
From: Zhang, Qi Z @ 2020-11-10 10:16 UTC (permalink / raw)
  To: Ananyev, Konstantin, Lu, Wenzhuo, dev; +Cc: Lu, Wenzhuo



> -----Original Message-----
> From: dev <dev-bounces@dpdk.org> On Behalf Of Ananyev, Konstantin
> Sent: Tuesday, November 10, 2020 6:05 PM
> To: Lu, Wenzhuo <wenzhuo.lu@intel.com>; dev@dpdk.org
> Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> Subject: Re: [dpdk-dev] [PATCH] net/ice: fix missed pointer check
> 
> 
> 
> > -----Original Message-----
> > From: dev <dev-bounces@dpdk.org> On Behalf Of Wenzhuo Lu
> > Sent: Tuesday, November 10, 2020 6:46 AM
> > To: dev@dpdk.org
> > Cc: Lu, Wenzhuo <wenzhuo.lu@intel.com>
> > Subject: [dpdk-dev] [PATCH] net/ice: fix missed pointer check
> >
> > The return value of rte_mempool_default_cache should be checked as it
> > can be NULL.
> >
> > Fixes: a4e480de268e ("net/ice: optimize Tx by using AVX512")
> >
> > Reported-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
> > Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
> > ---
> >  drivers/net/ice/ice_rxtx_vec_avx512.c | 8 +++++++-
> >  1 file changed, 7 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/ice/ice_rxtx_vec_avx512.c
> > b/drivers/net/ice/ice_rxtx_vec_avx512.c
> > index e5e7cc1..af6b324 100644
> > --- a/drivers/net/ice/ice_rxtx_vec_avx512.c
> > +++ b/drivers/net/ice/ice_rxtx_vec_avx512.c
> > @@ -781,9 +781,14 @@
> >
> >  	if (txq->offloads & DEV_TX_OFFLOAD_MBUF_FAST_FREE && (n & 31) == 0)
> {
> >  		struct rte_mempool *mp = txep[0].mbuf->pool;
> > +		void **cache_objs;
> >  		struct rte_mempool_cache *cache =
> rte_mempool_default_cache(mp,
> >  				rte_lcore_id());
> > -		void **cache_objs = &cache->objs[cache->len];
> > +
> > +		if (!cache || cache->len == 0)
> > +			goto normal;
> > +
> > +		cache_objs = &cache->objs[cache->len];
> >
> >  		if (n > RTE_MEMPOOL_CACHE_MAX_SIZE) {
> >  			rte_mempool_ops_enqueue_bulk(mp, (void *)txep, n); @@
> -821,6
> > +826,7 @@
> >  		goto done;
> >  	}
> >
> > +normal:
> >  	m = rte_pktmbuf_prefree_seg(txep[0].mbuf);
> >  	if (likely(m)) {
> >  		free[0] = m;
> > --
> 
> Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>

Applied to dpdk-next-net-intel.

Thanks
Qi
> 
> > 1.9.3


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

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

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-11-10  6:45 [dpdk-dev] [PATCH] net/ice: fix missed pointer check Wenzhuo Lu
2020-11-10 10:05 ` Ananyev, Konstantin
2020-11-10 10:16   ` Zhang, Qi Z

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git