[v1,1/1] baseband/acc: fix to possible negative shift

Message ID 20221102183050.12785-2-nicolas.chautru@intel.com (mailing list archive)
State Accepted, archived
Delegated to: akhil goyal
Headers
Series baseband/acc: coverity fix RC2 |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-aarch64-unit-testing success Testing PASS
ci/iol-aarch64-compile-testing success Testing PASS
ci/intel-Testing success Testing PASS
ci/iol-x86_64-unit-testing success Testing PASS
ci/iol-x86_64-compile-testing success Testing PASS
ci/github-robot: build success github build: passed

Commit Message

Chautru, Nicolas Nov. 2, 2022, 6:30 p.m. UTC
  Potential occurrence of negative shift when using invalid
configuration on ACC200. Enforcing that depth > 0.

Coverity issue: 381636
Fixes: 40e3adbdd3 ("baseband/acc200: add queue configuration")

Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
---
 drivers/baseband/acc/rte_acc200_pmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Akhil Goyal Nov. 3, 2022, 11:27 a.m. UTC | #1
> Potential occurrence of negative shift when using invalid
> configuration on ACC200. Enforcing that depth > 0.
> 
> Coverity issue: 381636
> Fixes: 40e3adbdd3 ("baseband/acc200: add queue configuration")
> 
> Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
Applied to dpdk-next-crypto

Thanks.
  

Patch

diff --git a/drivers/baseband/acc/rte_acc200_pmd.c b/drivers/baseband/acc/rte_acc200_pmd.c
index 8ee9023451..7d7a6c6389 100644
--- a/drivers/baseband/acc/rte_acc200_pmd.c
+++ b/drivers/baseband/acc/rte_acc200_pmd.c
@@ -105,9 +105,9 @@  aqDepth(int qg_idx, struct rte_acc_conf *acc_conf)
 	qtopFromAcc(&q_top, acc_enum, acc_conf);
 
 	if (unlikely(q_top == NULL))
-		return 0;
+		return 1;
 
-	return q_top->aq_depth_log2;
+	return RTE_MAX(1, q_top->aq_depth_log2);
 }
 
 /* Return the AQ depth for a Queue Group Index. */