Skip to contentSkip to conversation

DPDK Coverity issue 381631, 381646

PATCH Superseded Hernan Vargas 2 participants 5 messages Feb 8, 2023 – Feb 20, 2023

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover DPDK Coverity issue 381631, 381646

v2: Split code unrelated to coverity fix in separate commit.
v1: Upstream fix to 23.03 for potential issue of dereferencing a pointer before null check.

Hernan Vargas (2):
baseband/acc: fix check after deref and dead code baseband/acc: add check for empty queue

 drivers/baseband/acc/rte_acc100_pmd.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)
Signature · 1 line
2.37.1
#1 lore raw

PATCH v2 1/2 baseband/acc: fix check after deref and dead code

Fix potential issue of dereferencing a pointer before null check. Remove null check for value that could never be null.

Coverity issue: 381646, 381631

Fixes 989dec301a9 ("baseband/acc100: add ring companion address")
---
 drivers/baseband/acc/rte_acc100_pmd.c | 2 --
 1 file changed, 2 deletions(-)
drivers/baseband/acc/rte_acc100_pmd.c +0 -2
index 36f6fec5ad..baab459436 100644
@@ -4106,8 +4106,6 @@ acc100_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
 	int ret, cbm;
 	struct rte_bbdev_enc_op *op;
 
-	if (q == NULL)
-		return 0;
 #ifdef RTE_LIBRTE_BBDEV_DEBUG
 	if (unlikely(ops == 0))
 		return 0;
Signature · 1 line
2.37.1
Reviewed-by on v2 1/2
#2 lore raw

Re: [PATCH v2 1/2] baseband/acc: fix check after deref and dead code

Quoted 17 lines · Hernan Vargas

Fix potential issue of dereferencing a pointer before null check. Remove null check for value that could never be null.

Coverity issue: 381646, 381631

Fixes 989dec301a9 ("baseband/acc100: add ring companion address")
---
  drivers/baseband/acc/rte_acc100_pmd.c | 2 --
  1 file changed, 2 deletions(-)
drivers/baseband/acc/rte_acc100_pmd.c +0 -0
index 36f6fec5ad..baab459436 100644

drivers/baseband/acc/rte_acc100_pmd.c acc100_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data, · line 4111

Quoted 8 lines
drivers/baseband/acc/rte_acc100_pmd.c +0 -2
@@ -4106,8 +4106,6 @@ acc100_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
  	int ret, cbm;
  	struct rte_bbdev_enc_op *op;
 
-	if (q == NULL)
-		return 0;
  #ifdef RTE_LIBRTE_BBDEV_DEBUG
  	if (unlikely(ops == 0))
  		return 0;

Thanks,
Maxime

#3 lore raw

PATCH v2 2/2 baseband/acc: add check for empty queue

In reply to Hernan Vargas

Add optimization to return early if there are no available descriptors in ring to dequeue.

---
 drivers/baseband/acc/rte_acc100_pmd.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/baseband/acc/rte_acc100_pmd.c +2 -3
index baab459436..9941754aa0 100644
@@ -4106,10 +4106,9 @@ acc100_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
 	int ret, cbm;
 	struct rte_bbdev_enc_op *op;
 
-#ifdef RTE_LIBRTE_BBDEV_DEBUG
-	if (unlikely(ops == 0))
+	if (avail == 0)
 		return 0;
-#endif
+
 	op = acc_op_tail(q, 0);
 	if (unlikely(ops == NULL || op == NULL))
 		return 0;
Signature · 1 line
2.37.1
#4 lore raw

Re: [PATCH v2 2/2] baseband/acc: add check for empty queue

Hi Hernan,

Quoted 13 lines · Hernan Vargas

Add optimization to return early if there are no available descriptors in ring to dequeue.

---
  drivers/baseband/acc/rte_acc100_pmd.c | 5 ++---
  1 file changed, 2 insertions(+), 3 deletions(-)
drivers/baseband/acc/rte_acc100_pmd.c +0 -0
index baab459436..9941754aa0 100644

drivers/baseband/acc/rte_acc100_pmd.c acc100_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data, · line 4111

Quoted 9 lines
drivers/baseband/acc/rte_acc100_pmd.c +2 -3
@@ -4106,10 +4106,9 @@ acc100_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data,
  	int ret, cbm;
  	struct rte_bbdev_enc_op *op;
 
-#ifdef RTE_LIBRTE_BBDEV_DEBUG
-	if (unlikely(ops == 0))
+	if (avail == 0)
  		return 0;
-#endif
+

Again, this is doing more than advertised.

The patch intent is about returning early if no available descriptors, but here you also remove some debug checks.

At least please mention in in the commit message & title.

drivers/baseband/acc/rte_acc100_pmd.c acc100_dequeue_ldpc_enc(struct rte_bbdev_queue_data *q_data, · line 4114

Quoted 3 lines
drivers/baseband/acc/rte_acc100_pmd.c +0 -0
  	op = acc_op_tail(q, 0);
  	if (unlikely(ops == NULL || op == NULL))
  		return 0;

Thanks,
Maxime