net/mlx5: fix assert in doorbell lookup
The asserts makes sure that 'i' doesn't exceed the expected 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: 21cae8580f
("net/mlx5: allocate door-bells via DevX")
Cc: stable@dpdk.org
Signed-off-by: Asaf Penso <asafp@mellanox.com>
Reviewed-by: Dekel Peled <dekelp@mellanox.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@mellanox.com>
This commit is contained in:
parent
f21a98196a
commit
9b080425e3
@ -2149,8 +2149,8 @@ mlx5_get_dbr(struct rte_eth_dev *dev, struct mlx5_devx_dbr_page **dbr_page)
|
|||||||
i++)
|
i++)
|
||||||
; /* Empty. */
|
; /* Empty. */
|
||||||
/* Find the first clear bit. */
|
/* Find the first clear bit. */
|
||||||
|
MLX5_ASSERT(i < MLX5_DBR_BITMAP_SIZE);
|
||||||
j = rte_bsf64(~page->dbr_bitmap[i]);
|
j = rte_bsf64(~page->dbr_bitmap[i]);
|
||||||
MLX5_ASSERT(i < (MLX5_DBR_PER_PAGE / 64));
|
|
||||||
page->dbr_bitmap[i] |= (1 << j);
|
page->dbr_bitmap[i] |= (1 << j);
|
||||||
page->dbr_count++;
|
page->dbr_count++;
|
||||||
*dbr_page = page;
|
*dbr_page = page;
|
||||||
|
Loading…
Reference in New Issue
Block a user