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

Raslan Darawsheh rasland at mellanox.com
Wed Apr 29 12:36:16 CEST 2020


Hi,
> -----Original Message-----
> From: dev <dev-bounces at dpdk.org> On Behalf Of Asaf Penso
> Sent: Thursday, April 16, 2020 8:15 PM
> To: dev at dpdk.org
> Cc: Slava Ovsiienko <viacheslavo at mellanox.com>; Dekel Peled
> <dekelp at mellanox.com>; stable at dpdk.org
> Subject: [dpdk-dev] [PATCH] net/mlx5: fix location of assert function
> 
> 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


Patch applied to next-net-mlx,

Kindest regards,
Raslan Darawsheh



More information about the dev mailing list