mlxsw: spectrum_router: destroy FIB hash table on bind failure
Subsystems (3)
PATCH 1/1 mlxsw: spectrum_router: destroy FIB hash table on bind failure
mlxsw_sp_fib_create() initializes fib->ht before binding the LPM tree. If the bind fails, the error path releases the tree and frees fib without destroying the initialized hash table, leaking its bucket allocation.
Destroy fib->ht on the post-initialization failure path.
---
Compile-tested the affected object with x86_64 allmodconfig
and W=1 (GCC 13.3.0). Base: mainline 3b7cab693ba2bab63774bf5b988e8a61b2ef0f32. No hardware testing or runtime failure reproduction was performed.
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +1 -0
@@ -556,6 +556,7 @@ static struct mlxsw_sp_fib *mlxsw_sp_fib_create(struct mlxsw_sp *mlxsw_sp, err_lpm_tree_bind:mlxsw_sp_lpm_tree_put (mlxsw_sp, lpm_tree); +rhashtable_destroy (&fib->ht); err_rhashtable_init:kfree (fib);return ERR_PTR (err);
Quoted 28 lines · Sang-Hoon Choi
mlxsw_sp_fib_create()initializesfib->htbefore binding the LPM tree. If the bind fails, the error path releases the tree and frees fib without destroying the initialized hash table, leaking its bucket allocation.Destroy
fib->hton the post-initialization failure path.Fixes 2b52ce02e1d1 ("mlxsw: spectrum_router: Remove unnecessary prefix lengths from LPM tree")Reported-by Changyul Lee <[email protected]>Assisted-by LLMSigned-off-by Sang-Hoon Choi <[email protected]>---
Compile-tested the affected object withx86_64allmodconfig
and W=1 (GCC 13.3.0). Base: mainline3b7cab693ba2bab63774bf5b988e8a61b2ef0f32. No hardware testing or runtime failure reproduction was performed.
drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c| 1 +1 file changed, 1 insertion(+)drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +0
-0@@ -556,6 +556,7 @@ static struct mlxsw_sp_fib *mlxsw_sp_fib_create(struct mlxsw_sp *mlxsw_sp,
err_lpm_tree_bind:mlxsw_sp_lpm_tree_put(mlxsw_sp, lpm_tree);drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c +1
-0+rhashtable_destroy (&fib->ht);
err_rhashtable_init:
Quoted 3 lines
kfree(fib); return ERR_PTR(err);
Quoted 10 lines · Sang-Hoon Choi
mlxsw_sp_fib_create()initializesfib->htbefore binding the LPM tree. If the bind fails, the error path releases the tree and frees fib without destroying the initialized hash table, leaking its bucket allocation.Destroy
fib->hton the post-initialization failure path.Fixes 2b52ce02e1d1 ("mlxsw: spectrum_router: Remove unnecessary prefix lengths from LPM tree")Reported-by Changyul Lee <[email protected]>Assisted-by LLMSigned-off-by Sang-Hoon Choi <[email protected]>
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:
Quoted 4 lines · On Fri, 02 Oct 2026 19:47:40 +0000 you wrote:
mlxsw_sp_fib_create()initializesfib->htbefore binding the LPM tree. If the bind fails, the error path releases the tree and frees fib without destroying the initialized hash table, leaking its bucket allocation.
Quoted 8 lines
Destroy
fib->hton the post-initialization failure path.Fixes 2b52ce02e1d1 ("mlxsw: spectrum_router: Remove unnecessary prefix lengths from LPM tree")Reported-by Changyul Lee <[email protected]>Assisted-by LLMSigned-off-by Sang-Hoon Choi <[email protected]>[...]
Here is the summary with links:
- [net] mlxsw: spectrum_router: destroy FIB hash table on bind failure
https://git.kernel.org/netdev/net-next/c/a089139eb47b
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html