]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
net/mlx5: HWS, Fix memory leak in hws_pool_buddy_init error path
authorLama Kayal <lkayal@nvidia.com>
Mon, 25 Aug 2025 14:34:24 +0000 (17:34 +0300)
committerJakub Kicinski <kuba@kernel.org>
Wed, 27 Aug 2025 01:00:25 +0000 (18:00 -0700)
In the error path of hws_pool_buddy_init(), the buddy allocator cleanup
doesn't free the allocator structure itself, causing a memory leak.

Add the missing kfree() to properly release all allocated memory.

Fixes: c61afff94373 ("net/mlx5: HWS, added memory management handling")
Signed-off-by: Lama Kayal <lkayal@nvidia.com>
Reviewed-by: Tariq Toukan <tariqt@nvidia.com>
Signed-off-by: Mark Bloch <mbloch@nvidia.com>
Link: https://patch.msgid.link/20250825143435.598584-2-mbloch@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/steering/hws/pool.c

index 7e37d6e9eb83610981d9762ef84be4e0a5349ff9..7b5071c3df368b02660c534f3aeff4b3a367c8ac 100644 (file)
@@ -124,6 +124,7 @@ static int hws_pool_buddy_init(struct mlx5hws_pool *pool)
                mlx5hws_err(pool->ctx, "Failed to create resource type: %d size %zu\n",
                            pool->type, pool->alloc_log_sz);
                mlx5hws_buddy_cleanup(buddy);
+               kfree(buddy);
                return -ENOMEM;
        }