[dpdk-dev] [PATCH] net/mlx5: fix location of assert function

Asaf Penso asafp at mellanox.com
Thu Apr 16 19:15:09 CEST 2020


The asserts makes sure that 'i' doesn't exceed the exepcted value.
This to prevent an out of bound access to dbr_bitmap.

The current location of the assert protects the assignment of
dbr_bitmap, but not the access to it.

Moved the assert to the correct place, to protect both cases.
Also, used an existing define for the assert.

Fixes: 21cae858 ("net/mlx5: allocate door-bells via DevX")
Cc: stable at dpdk.org

Signed-off-by: Asaf Penso <asafp at mellanox.com>
Reviewed-by: Dekel Peled <dekelp at mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo at mellanox.com>
---
 drivers/net/mlx5/mlx5.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5.c b/drivers/net/mlx5/mlx5.c
index f8b134c..df12a3b 100644
--- a/drivers/net/mlx5/mlx5.c
+++ b/drivers/net/mlx5/mlx5.c
@@ -1989,8 +1989,8 @@ struct mlx5_flow_id_pool *
 	     i++)
 		; /* Empty. */
 	/* Find the first clear bit. */
+	MLX5_ASSERT(i < MLX5_DBR_BITMAP_SIZE);
 	j = rte_bsf64(~page->dbr_bitmap[i]);
-	MLX5_ASSERT(i < (MLX5_DBR_PER_PAGE / 64));
 	page->dbr_bitmap[i] |= (1 << j);
 	page->dbr_count++;
 	*dbr_page = page;
-- 
1.8.3.1



More information about the dev mailing list