net/mlx5: fix incorrect buddy mempool init
PATCH 3/4 net/mlx5: fix incorrect buddy mempool init
From: Nupur Uttarwar <[email protected]>
buddy was erroroneously declared as static. When multiple threads call this routine, they set the same static variable corrupting pool data and can cause potential double free when releasing resources.
Fixes b4dd7bcb0dcb ("net/mlx5/hws: add pool and buddy")
Signed-off-by Nupur Uttarwar <[email protected]>
--- drivers/net/mlx5/hws/mlx5dr_buddy.c | 1 + drivers/net/mlx5/hws/mlx5dr_pool.c | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-)
drivers/net/mlx5/hws/mlx5dr_buddy.c +1 -0
@@ -147,6 +147,7 @@ void mlx5dr_buddy_cleanup(struct mlx5dr_buddy_mem *buddy)simple_free (buddy->num_free);simple_free (buddy->bits); +simple_free (buddy); }int mlx5dr_buddy_alloc_mem (struct mlx5dr_buddy_mem *buddy,int order)
drivers/net/mlx5/hws/mlx5dr_pool.c +1 -2
@@ -167,7 +167,7 @@ static struct mlx5dr_buddy_mem * mlx5dr_pool_buddy_get_next_buddy(struct mlx5dr_pool *pool, int idx, uint32_t order, bool *is_new_buddy) { - static struct mlx5dr_buddy_mem *buddy; + struct mlx5dr_buddy_mem *buddy;uint32_t new_buddy_size; buddy = pool->db.buddy_manager->buddies[idx];
@@ -271,7 +271,6 @@ static void mlx5dr_pool_buddy_db_uninit(struct mlx5dr_pool *pool) buddy = pool->db.buddy_manager->buddies[i];if (buddy) {mlx5dr_buddy_cleanup (buddy); -simple_free (buddy); pool->db.buddy_manager->buddies[i] =NULL ; } }
Signature · 1 line
2.34.1
Quoted 10 lines · Bing Zhao
From: Nupur Uttarwar <[email protected]>
buddywas erroroneously declared as static. When multiple threads call this routine, they set the same static variable corrupting pool data and can cause potential double free when releasing resources.Fixes b4dd7bcb0dcb ("net/mlx5/hws: add pool and buddy")Signed-off-by Nupur Uttarwar <[email protected]>