DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH 0/2] fix coverity issues
@ 2024-07-17  3:24 Chaoyong He
  2024-07-17  3:24 ` [PATCH 1/2] net/nfp: fix copy and paste error Chaoyong He
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Chaoyong He @ 2024-07-17  3:24 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He

This patch series fix two coverity issues:
- 439964
- 439967

Chaoyong He (1):
  net/nfp: fix copy and paste error

Long Wu (1):
  net/nfp: fix AVX2 vector Rx function memory overrun

 drivers/net/nfp/flower/nfp_flower_flow.c |  4 +--
 drivers/net/nfp/nfp_rxtx_vec_avx2.c      | 41 +++++++++++++++---------
 2 files changed, 27 insertions(+), 18 deletions(-)

-- 
2.39.1


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

* [PATCH 1/2] net/nfp: fix copy and paste error
  2024-07-17  3:24 [PATCH 0/2] fix coverity issues Chaoyong He
@ 2024-07-17  3:24 ` Chaoyong He
  2024-07-17  3:24 ` [PATCH 2/2] net/nfp: fix AVX2 vector Rx function memory overrun Chaoyong He
  2024-07-19  7:40 ` [PATCH 0/2] fix coverity issues Ferruh Yigit
  2 siblings, 0 replies; 4+ messages in thread
From: Chaoyong He @ 2024-07-17  3:24 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Chaoyong He, Long Wu, Peng Zhang

CI found copy and paste error occurs.

Coverity issue: 439967
Fixes: 830057d1dba9 ("net/nfp: refactor flow action compile function")

Signed-off-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/flower/nfp_flower_flow.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/net/nfp/flower/nfp_flower_flow.c b/drivers/net/nfp/flower/nfp_flower_flow.c
index cf2b919e7e..0078455658 100644
--- a/drivers/net/nfp/flower/nfp_flower_flow.c
+++ b/drivers/net/nfp/flower/nfp_flower_flow.c
@@ -4458,7 +4458,7 @@ nfp_flow_action_compile_ttl(struct nfp_action_compile_param *param)
 		}
 	} else {
 		nfp_flow_action_set_hl(param->position, param->action,
-				param->flag->ttl_tos_flag);
+				param->flag->tc_hl_flag);
 		if (!param->flag->tc_hl_flag) {
 			param->position += sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
 			param->flag->tc_hl_flag = true;
@@ -4485,7 +4485,7 @@ static int
 nfp_flow_action_compile_ipv6_dscp(struct nfp_action_compile_param *param)
 {
 	nfp_flow_action_set_tc(param->position, param->action,
-			param->flag->ttl_tos_flag);
+			param->flag->tc_hl_flag);
 	if (!param->flag->tc_hl_flag) {
 		param->position += sizeof(struct nfp_fl_act_set_ipv6_tc_hl_fl);
 		param->flag->tc_hl_flag = true;
-- 
2.39.1


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

* [PATCH 2/2] net/nfp: fix AVX2 vector Rx function memory overrun
  2024-07-17  3:24 [PATCH 0/2] fix coverity issues Chaoyong He
  2024-07-17  3:24 ` [PATCH 1/2] net/nfp: fix copy and paste error Chaoyong He
@ 2024-07-17  3:24 ` Chaoyong He
  2024-07-19  7:40 ` [PATCH 0/2] fix coverity issues Ferruh Yigit
  2 siblings, 0 replies; 4+ messages in thread
From: Chaoyong He @ 2024-07-17  3:24 UTC (permalink / raw)
  To: dev; +Cc: oss-drivers, Long Wu, Chaoyong He, Peng Zhang

From: Long Wu <long.wu@corigine.com>

CI found that the 'rxb' in 'nfp_net_vec_avx2_recv_pkts()' may
cause memory overrun.

Coverity issue:439964
Fixes: b67555307628 ("net/nfp: add AVX2 Rx")

Signed-off-by: Long Wu <long.wu@corigine.com>
Reviewed-by: Chaoyong He <chaoyong.he@corigine.com>
Reviewed-by: Peng Zhang <peng.zhang@corigine.com>
---
 drivers/net/nfp/nfp_rxtx_vec_avx2.c | 41 ++++++++++++++++++-----------
 1 file changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/net/nfp/nfp_rxtx_vec_avx2.c b/drivers/net/nfp/nfp_rxtx_vec_avx2.c
index 508ec7faa5..2a033133a1 100644
--- a/drivers/net/nfp/nfp_rxtx_vec_avx2.c
+++ b/drivers/net/nfp/nfp_rxtx_vec_avx2.c
@@ -117,29 +117,48 @@ nfp_vec_avx2_recv_set_rxpkt1(struct nfp_net_rxq *rxq,
 	nfp_net_rx_cksum(rxq, rxds, rx_pkt);
 }
 
-static inline void
+static inline int
 nfp_vec_avx2_recv1(struct nfp_net_rxq *rxq,
 		struct nfp_net_rx_desc *rxds,
-		struct rte_mbuf *rxb,
+		struct rte_mbuf **rxb,
 		struct rte_mbuf *rx_pkt)
 {
+	/* Allocate a new mbuf into the software ring. */
+	if (rte_pktmbuf_alloc_bulk(rxq->mem_pool, rxb, 1) < 0) {
+		PMD_RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u queue_id=%hu",
+				rxq->port_id, rxq->qidx);
+		nfp_net_mbuf_alloc_failed(rxq);
+		return -ENOMEM;
+	}
+
 	nfp_vec_avx2_recv_set_rxpkt1(rxq, rxds, rx_pkt);
 
-	nfp_vec_avx2_recv_set_des1(rxq, rxds, rxb);
+	nfp_vec_avx2_recv_set_des1(rxq, rxds, *rxb);
+
+	return 0;
 }
 
-static inline void
+static inline int
 nfp_vec_avx2_recv4(struct nfp_net_rxq *rxq,
 		struct nfp_net_rx_desc *rxds,
 		struct rte_mbuf **rxb,
 		struct rte_mbuf **rx_pkts)
 {
+	/* Allocate 4 new mbufs into the software ring. */
+	if (rte_pktmbuf_alloc_bulk(rxq->mem_pool, rxb, 4) < 0) {
+		PMD_RX_LOG(DEBUG, "RX mbuf bulk alloc failed port_id=%u queue_id=%hu",
+				rxq->port_id, rxq->qidx);
+		return -ENOMEM;
+	}
+
 	nfp_vec_avx2_recv_set_rxpkt1(rxq, rxds, rx_pkts[0]);
 	nfp_vec_avx2_recv_set_rxpkt1(rxq, rxds + 1, rx_pkts[1]);
 	nfp_vec_avx2_recv_set_rxpkt1(rxq, rxds + 2, rx_pkts[2]);
 	nfp_vec_avx2_recv_set_rxpkt1(rxq, rxds + 3, rx_pkts[3]);
 
 	nfp_vec_avx2_recv_set_des4(rxq, rxds, rxb);
+
+	return 0;
 }
 
 static inline bool
@@ -215,15 +234,8 @@ nfp_net_vec_avx2_recv_pkts(void *rx_queue,
 			_mm_storel_epi64((void *)&rx_pkts[avail],
 					_mm_loadu_si128((void *)rxb));
 
-			/* Allocate a new mbuf into the software ring. */
-			if (rte_pktmbuf_alloc_bulk(rxq->mem_pool, rxb, 1) < 0) {
-				PMD_RX_LOG(DEBUG, "RX mbuf alloc failed port_id=%u queue_id=%hu",
-						rxq->port_id, rxq->qidx);
-				nfp_net_mbuf_alloc_failed(rxq);
+			if (nfp_vec_avx2_recv1(rxq, rxds, rxb, rx_pkts[avail]) != 0)
 				goto recv_end;
-			}
-
-			nfp_vec_avx2_recv1(rxq, rxds, *rxb, rx_pkts[avail]);
 
 			avail++;
 			nb_hold++;
@@ -237,14 +249,11 @@ nfp_net_vec_avx2_recv_pkts(void *rx_queue,
 		_mm256_storeu_si256((void *)&rx_pkts[avail],
 				_mm256_loadu_si256((void *)rxb));
 
-		/* Allocate 4 new mbufs into the software ring. */
-		if (rte_pktmbuf_alloc_bulk(rxq->mem_pool, rxb, 4) < 0) {
+		if (nfp_vec_avx2_recv4(rxq, rxds, rxb, &rx_pkts[avail]) != 0) {
 			burst_receive = false;
 			continue;
 		}
 
-		nfp_vec_avx2_recv4(rxq, rxds, rxb, &rx_pkts[avail]);
-
 		avail += 4;
 		nb_hold += 4;
 	}
-- 
2.39.1


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

* Re: [PATCH 0/2] fix coverity issues
  2024-07-17  3:24 [PATCH 0/2] fix coverity issues Chaoyong He
  2024-07-17  3:24 ` [PATCH 1/2] net/nfp: fix copy and paste error Chaoyong He
  2024-07-17  3:24 ` [PATCH 2/2] net/nfp: fix AVX2 vector Rx function memory overrun Chaoyong He
@ 2024-07-19  7:40 ` Ferruh Yigit
  2 siblings, 0 replies; 4+ messages in thread
From: Ferruh Yigit @ 2024-07-19  7:40 UTC (permalink / raw)
  To: Chaoyong He, dev; +Cc: oss-drivers

On 7/17/2024 4:24 AM, Chaoyong He wrote:
> This patch series fix two coverity issues:
> - 439964
> - 439967
> 
> Chaoyong He (1):
>   net/nfp: fix copy and paste error
> 
> Long Wu (1):
>   net/nfp: fix AVX2 vector Rx function memory overrun
>

Series applied to dpdk-next-net/main, thanks.


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

end of thread, other threads:[~2024-07-19  8:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-07-17  3:24 [PATCH 0/2] fix coverity issues Chaoyong He
2024-07-17  3:24 ` [PATCH 1/2] net/nfp: fix copy and paste error Chaoyong He
2024-07-17  3:24 ` [PATCH 2/2] net/nfp: fix AVX2 vector Rx function memory overrun Chaoyong He
2024-07-19  7:40 ` [PATCH 0/2] fix coverity issues 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).