Skip to contentSkip to conversation

net/i40e: fix unchecked return value

PATCH Superseded Beilei Xing 3 participants 5 messages Feb 11, 2020 – Feb 14, 2020 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net/i40e: fix unchecked return value

Check the return value of the i40e_xmit_cleanup function.

Coverity issue: 353617

Fixes 4861cde46116 ("i40e: new poll mode driver")
---
 drivers/net/i40e/i40e_rxtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_rxtx.c +3 -2
index fd1ae80..f43fc0f 100644
@@ -1038,8 +1038,9 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	txe = &sw_ring[tx_id];
 
 	/* Check if the descriptor ring needs to be cleaned. */
-	if (txq->nb_tx_free < txq->tx_free_thresh)
-		i40e_xmit_cleanup(txq);
+	if ((txq->nb_tx_free < txq->tx_free_thresh) &&
+	    (i40e_xmit_cleanup(txq) != 0))
+		return 0;
 
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
 		td_cmd = 0;
Signature · 1 line
2.7.4
#1 lore raw
Quoted 15 lines · Beilei Xing

Check the return value of the i40e_xmit_cleanup function.

Coverity issue: 353617

Fixes 4861cde46116 ("i40e: new poll mode driver")
---
 drivers/net/i40e/i40e_rxtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/net/i40e/i40e_rxtx.c +0 -0
index fd1ae80..f43fc0f 100644

drivers/net/i40e/i40e_rxtx.c i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) · line 1044

Quoted 9 lines
drivers/net/i40e/i40e_rxtx.c +3 -2
@@ -1038,8 +1038,9 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 	txe = &sw_ring[tx_id];
 
 	/* Check if the descriptor ring needs to be cleaned. */
-	if (txq->nb_tx_free < txq->tx_free_thresh)
-		i40e_xmit_cleanup(txq);
+	if ((txq->nb_tx_free < txq->tx_free_thresh) &&
+	    (i40e_xmit_cleanup(txq) != 0))
+		return 0;
 

I don't think this should be fixed, and the original code is correct.

This cleanup is opportunistic and may not cause problems if it fails. For example, if tx_free_thresh is 32, and nb_tx_free is 24, there is no reason to return zero here if the total packets to be sent it 16 - since all packets can feasibly fit. Even if we had 32 to transmit, we still should not quit here, since any packets that can be transmitted should be sent, and there is a subsequent cleanup call at line 1084 to handle failed cleanup when it does become a problem.

Regards,
/Bruce

#2 lore raw
Quoted 36 lines

-----Original Message-----
From: Bruce Richardson <[email protected]>
Sent: Tuesday, February 11, 2020 7:42 PM
To: Xing, Beilei <[email protected]>
Cc: [email protected]; Zhang, Qi Z <[email protected]>
Subject: Re: [dpdk-dev] [PATCH] net/i40e: fix unchecked return value

drivers/net/i40e/i40e_rxtx.c i40e_xmit_pkts(void *tx_queue, struct rte_mbuf

Quoted 15 lines · Beilei Xing

Check the return value of the i40e_xmit_cleanup function.

Coverity issue: 353617

Fixes 4861cde46116 ("i40e: new poll mode driver")
---
 drivers/net/i40e/i40e_rxtx.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
(quoted diff) +0 -0

b/drivers/net/i40e/i40e_rxtx.c index fd1ae80..f43fc0f 100644

drivers/net/i40e/i40e_rxtx.c +0 -0
@@ -1038,8 +1038,9 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf

**tx_pkts, uint16_t nb_pkts)

drivers/net/i40e/i40e_rxtx.c i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts) · line 1044

Quoted 9 lines
drivers/net/i40e/i40e_rxtx.c +3 -2
 	txe = &sw_ring[tx_id];
 
 	/* Check if the descriptor ring needs to be cleaned. */
-	if (txq->nb_tx_free < txq->tx_free_thresh)
-		i40e_xmit_cleanup(txq);
+	if ((txq->nb_tx_free < txq->tx_free_thresh) &&
+	    (i40e_xmit_cleanup(txq) != 0))
+		return 0;
 

I don't think this should be fixed, and the original code is correct.

Quoted 7 lines

This cleanup is opportunistic and may not cause problems if it fails. For example, if tx_free_thresh is 32, and nb_tx_free is 24, there is no reason to return zero here if the total packets to be sent it 16 - since all packets can feasibly fit. Even if we had 32 to transmit, we still should not quit here, since any packets that can be transmitted should be sent, and there is a subsequent cleanup call at line 1084 to handle failed cleanup when it does become a problem.

Yes, agree. Will abandon the patch. Thanks.

Quoted 3 lines

Regards,
/Bruce

#3 lore raw

PATCH v2 1/1 net/i40e: fix unchecked return value

In reply to Beilei Xing

This patch fixes unchecked return value
of the i40e_xmit_cleanup function.

Coverity issue: 353617

Fixes 4861cde46116 ("i40e: new poll mode driver")

---
V2 change:
- Use cast.

 drivers/net/i40e/i40e_rxtx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/i40e/i40e_rxtx.c +1 -1
index fd1ae80..f6d23c9 100644
@@ -1039,7 +1039,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 	/* Check if the descriptor ring needs to be cleaned. */
 	if (txq->nb_tx_free < txq->tx_free_thresh)
-		i40e_xmit_cleanup(txq);
+		(void)i40e_xmit_cleanup(txq);
 
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
 		td_cmd = 0;
Signature · 1 line
2.7.4
Acked-by on v2 1/1 Applied
#4 lore raw
Quoted 30 lines · Beilei Xing

This patch fixes unchecked return value
of the i40e_xmit_cleanup function.

Coverity issue: 353617

Fixes 4861cde46116 ("i40e: new poll mode driver")

---
V2 change:
- Use cast.

drivers/net/i40e/i40e_rxtx.c | 2 +-

1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/i40e/i40e_rxtx.c +1 -1
index fd1ae80..f6d23c9 100644
@@ -1039,7 +1039,7 @@ i40e_xmit_pkts(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 
 	/* Check if the descriptor ring needs to be cleaned. */
 	if (txq->nb_tx_free < txq->tx_free_thresh)
-		i40e_xmit_cleanup(txq);
+		(void)i40e_xmit_cleanup(txq);
 
 	for (nb_tx = 0; nb_tx < nb_pkts; nb_tx++) {
 		td_cmd = 0;
Signature · 1 line
2.7.4

Applied to dpdk-next-net-intel, Thanks.