[v1,7/9] baseband/acc: fix potential arithmetic overflow Fix potential issue of overflow causing coverity warning.

Message ID 20230209221929.265059-8-nicolas.chautru@intel.com (mailing list archive)
State Superseded, archived
Delegated to: Maxime Coquelin
Headers
Series baseband/acc: VRB PMD fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Chautru, Nicolas Feb. 9, 2023, 10:19 p.m. UTC
  Coverity issue: 383154
Fixes: 8e16839937 ("baseband/acc: extension of the device structure")
Cc: stable@dpdk.org

Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
---
 drivers/baseband/acc/rte_vrb_pmd.c | 2 +-
 drivers/baseband/acc/vrb_pmd.h     | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)
  

Comments

Maxime Coquelin Feb. 10, 2023, 9:41 a.m. UTC | #1
There seems to be formatting issue of the commit log,
the commit message is appended to the title.


On 2/9/23 23:19, Nicolas Chautru wrote:
> Coverity issue: 383154
> Fixes: 8e16839937 ("baseband/acc: extension of the device structure")
> Cc: stable@dpdk.org
> 
> Signed-off-by: Nicolas Chautru <nicolas.chautru@intel.com>
> ---
>   drivers/baseband/acc/rte_vrb_pmd.c | 2 +-
>   drivers/baseband/acc/vrb_pmd.h     | 1 +
>   2 files changed, 2 insertions(+), 1 deletion(-)

With commit log fixed:

Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>

Thanks,
Maxime


> diff --git a/drivers/baseband/acc/rte_vrb_pmd.c b/drivers/baseband/acc/rte_vrb_pmd.c
> index 0bd5c65177..8fcb06b4ff 100644
> --- a/drivers/baseband/acc/rte_vrb_pmd.c
> +++ b/drivers/baseband/acc/rte_vrb_pmd.c
> @@ -518,7 +518,7 @@ vrb_setup_queues(struct rte_bbdev *dev, uint16_t num_queues, int socket_id)
>   	if (d->tail_ptrs == NULL)
>   		d->tail_ptrs = rte_zmalloc_socket(
>   				dev->device->driver->name,
> -				d->num_qgroups * d->num_aqs * sizeof(uint32_t),
> +				VRB_MAX_QGRPS * VRB_MAX_AQS * sizeof(uint32_t),
>   				RTE_CACHE_LINE_SIZE, socket_id);
>   	if (d->tail_ptrs == NULL) {
>   		rte_bbdev_log(ERR, "Failed to allocate tail ptr for %s:%u",
> diff --git a/drivers/baseband/acc/vrb_pmd.h b/drivers/baseband/acc/vrb_pmd.h
> index f3c9239881..01028273e7 100644
> --- a/drivers/baseband/acc/vrb_pmd.h
> +++ b/drivers/baseband/acc/vrb_pmd.h
> @@ -36,6 +36,7 @@
>   
>   #define VRB_NUM_ACCS                 6
>   #define VRB_MAX_QGRPS                32
> +#define VRB_MAX_AQS                  32
>   
>   #define ACC_STATUS_WAIT      10
>   #define ACC_STATUS_TO        100
  

Patch

diff --git a/drivers/baseband/acc/rte_vrb_pmd.c b/drivers/baseband/acc/rte_vrb_pmd.c
index 0bd5c65177..8fcb06b4ff 100644
--- a/drivers/baseband/acc/rte_vrb_pmd.c
+++ b/drivers/baseband/acc/rte_vrb_pmd.c
@@ -518,7 +518,7 @@  vrb_setup_queues(struct rte_bbdev *dev, uint16_t num_queues, int socket_id)
 	if (d->tail_ptrs == NULL)
 		d->tail_ptrs = rte_zmalloc_socket(
 				dev->device->driver->name,
-				d->num_qgroups * d->num_aqs * sizeof(uint32_t),
+				VRB_MAX_QGRPS * VRB_MAX_AQS * sizeof(uint32_t),
 				RTE_CACHE_LINE_SIZE, socket_id);
 	if (d->tail_ptrs == NULL) {
 		rte_bbdev_log(ERR, "Failed to allocate tail ptr for %s:%u",
diff --git a/drivers/baseband/acc/vrb_pmd.h b/drivers/baseband/acc/vrb_pmd.h
index f3c9239881..01028273e7 100644
--- a/drivers/baseband/acc/vrb_pmd.h
+++ b/drivers/baseband/acc/vrb_pmd.h
@@ -36,6 +36,7 @@ 
 
 #define VRB_NUM_ACCS                 6
 #define VRB_MAX_QGRPS                32
+#define VRB_MAX_AQS                  32
 
 #define ACC_STATUS_WAIT      10
 #define ACC_STATUS_TO        100