* [PATCH 3/4] net/mlx5: fix incorrect buddy mempool init
@ 2025-11-12 7:47 Bing Zhao
2025-11-12 9:48 ` Dariusz Sosnowski
0 siblings, 1 reply; 2+ messages in thread
From: Bing Zhao @ 2025-11-12 7:47 UTC (permalink / raw)
To: viacheslavo, dev, rasland
Cc: orika, dsosnowski, suanmingm, matan, thomas, bingz, Nupur Uttarwar
From: Nupur Uttarwar <nuttarwar@nvidia.com>
`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 <nuttarwar@nvidia.com>
---
drivers/net/mlx5/hws/mlx5dr_buddy.c | 1 +
drivers/net/mlx5/hws/mlx5dr_pool.c | 3 +--
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/mlx5/hws/mlx5dr_buddy.c b/drivers/net/mlx5/hws/mlx5dr_buddy.c
index 394ca71217..abfbdf1be5 100644
--- a/drivers/net/mlx5/hws/mlx5dr_buddy.c
+++ b/drivers/net/mlx5/hws/mlx5dr_buddy.c
@@ -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)
diff --git a/drivers/net/mlx5/hws/mlx5dr_pool.c b/drivers/net/mlx5/hws/mlx5dr_pool.c
index 8e3718ac42..e383027d3e 100644
--- a/drivers/net/mlx5/hws/mlx5dr_pool.c
+++ b/drivers/net/mlx5/hws/mlx5dr_pool.c
@@ -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;
}
}
--
2.34.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH 3/4] net/mlx5: fix incorrect buddy mempool init
2025-11-12 7:47 [PATCH 3/4] net/mlx5: fix incorrect buddy mempool init Bing Zhao
@ 2025-11-12 9:48 ` Dariusz Sosnowski
0 siblings, 0 replies; 2+ messages in thread
From: Dariusz Sosnowski @ 2025-11-12 9:48 UTC (permalink / raw)
To: Bing Zhao
Cc: viacheslavo, dev, rasland, orika, suanmingm, matan, thomas,
Nupur Uttarwar
On Wed, Nov 12, 2025 at 09:47:39AM +0200, Bing Zhao wrote:
> From: Nupur Uttarwar <nuttarwar@nvidia.com>
>
> `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 <nuttarwar@nvidia.com>
Acked-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-11-12 9:48 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-12 7:47 [PATCH 3/4] net/mlx5: fix incorrect buddy mempool init Bing Zhao
2025-11-12 9:48 ` Dariusz Sosnowski
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).