Skip to contentSkip to conversation

net/iavf: fix missed pointer check

PATCH Applied Wenzhuo Lu 3 participants 3 messages Nov 10, 2020 Network drivers

lore
Share & tools
lore

Wenzhuo Lu

author
#0 lore raw

PATCH 1/1 net/iavf: fix missed pointer check

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

Fixes 9ab9514c150e ("net/iavf: enable AVX512 for Tx")
---
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/iavf/iavf_rxtx_vec_avx512.c +7 -1
index 8680734..584d12e 100644
@@ -1424,7 +1424,12 @@
 		struct rte_mempool *mp = txep[0].mbuf->pool;
 		struct rte_mempool_cache *cache = rte_mempool_default_cache(mp,
 								rte_lcore_id());
-		void **cache_objs = &cache->objs[cache->len];
+		void **cache_objs;
+
+		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);
@@ -1462,6 +1467,7 @@
 		goto done;
 	}
 
+normal:
 	m = rte_pktmbuf_prefree_seg(txep[0].mbuf);
 	if (likely(m)) {
 		free[0] = m;
Signature · 1 line
1.9.3
Acked-by on v1 1/1
#1 lore raw
Quoted 32 lines

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

Fixes 9ab9514c150e ("net/iavf: enable AVX512 for Tx")
---
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/iavf/iavf_rxtx_vec_avx512.c +6 -1
index 8680734..584d12e 100644
@@ -1424,7 +1424,12 @@
 		struct rte_mempool *mp = txep[0].mbuf->pool;
 		struct rte_mempool_cache *cache = rte_mempool_default_cache(mp,
 								rte_lcore_id());
-		void **cache_objs = &cache->objs[cache->len];
+		void **cache_objs;
+
+		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);

drivers/net/iavf/iavf_rxtx_vec_avx512.c

Quoted 8 lines
drivers/net/iavf/iavf_rxtx_vec_avx512.c +1 -1
@@ -1462,6 +1467,7 @@
 		goto done;
 	}
 
+normal:
 	m = rte_pktmbuf_prefree_seg(txep[0].mbuf);
 	if (likely(m)) {
 		free[0] = m;
--
Quoted 1 line

1.9.3

Applied
#2 lore raw
Quoted 47 lines

-----Original Message-----
From: dev <[email protected]> On Behalf Of Ananyev, Konstantin
Sent: Tuesday, November 10, 2020 6:06 PM
To: Lu, Wenzhuo <[email protected]>; [email protected]
Cc: Lu, Wenzhuo <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] net/iavf: fix missed pointer check

Quoted 17 lines

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

Fixes 9ab9514c150e ("net/iavf: enable AVX512 for Tx")
---
 drivers/net/iavf/iavf_rxtx_vec_avx512.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
drivers/net/iavf/iavf_rxtx_vec_avx512.c +0 -0
index 8680734..584d12e 100644

drivers/net/iavf/iavf_rxtx_vec_avx512.c line 1425

Quoted 2 lines
drivers/net/iavf/iavf_rxtx_vec_avx512.c +0 -0
@@ -1424,7 +1424,12 @@
 		struct rte_mempool *mp = txep[0].mbuf->pool;
 		struct rte_mempool_cache *cache =

rte_mempool_default_cache(mp,

drivers/net/iavf/iavf_rxtx_vec_avx512.c

Quoted 11 lines
drivers/net/iavf/iavf_rxtx_vec_avx512.c +6 -1
 								rte_lcore_id());
-		void **cache_objs = &cache->objs[cache->len];
+		void **cache_objs;
+
+		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); @@

-1462,6

Quoted 4 lines

+1467,7 @@

drivers/net/iavf/iavf_rxtx_vec_avx512.c +0 -0
 		goto done;
 	}
Quoted 7 lines

drivers/net/iavf/iavf_rxtx_vec_avx512.c

Quoted 5 lines
drivers/net/iavf/iavf_rxtx_vec_avx512.c +1 -1
+normal:
 	m = rte_pktmbuf_prefree_seg(txep[0].mbuf);
 	if (likely(m)) {
 		free[0] = m;
--

Applied to dpdk-next-net-intel.

Thanks
Qi

Quoted 2 lines
Quoted 2 lines

1.9.3