Netdev List
 help / color / mirror / Atom feed
* [PATCH net] mlxsw: spectrum_router: destroy FIB hash table on bind failure
@ 2026-10-02 19:47 Sang-Hoon Choi
  2026-10-03 10:00 ` Ivan Vecera
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Sang-Hoon Choi @ 2026-10-02 19:47 UTC (permalink / raw)
  To: Ido Schimmel, Petr Machata; +Cc: netdev, Jiri Pirko, Changyul Lee

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.

Fixes: 2b52ce02e1d1 ("mlxsw: spectrum_router: Remove unnecessary prefix lengths from LPM tree")
Reported-by: Changyul Lee <lcy8047@gmail.com>
Assisted-by: LLM
Signed-off-by: Sang-Hoon Choi <csh0052@gmail.com>
---
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(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
index 3d6fdbab05e0..456c60b9be17 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
@@ -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);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH net] mlxsw: spectrum_router: destroy FIB hash table on bind failure
  2026-10-02 19:47 [PATCH net] mlxsw: spectrum_router: destroy FIB hash table on bind failure Sang-Hoon Choi
@ 2026-10-03 10:00 ` Ivan Vecera
  2026-10-04  7:47 ` Ido Schimmel
  2026-10-06  0:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Ivan Vecera @ 2026-10-03 10:00 UTC (permalink / raw)
  To: Sang-Hoon Choi, Ido Schimmel, Petr Machata
  Cc: netdev, Jiri Pirko, Changyul Lee

On October 2, 2026 9:47:40 PM GMT+02:00, Sang-Hoon Choi <csh0052@gmail.com> wrote:
>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.
>
>Fixes: 2b52ce02e1d1 ("mlxsw: spectrum_router: Remove unnecessary prefix lengths from LPM tree")
>Reported-by: Changyul Lee <lcy8047@gmail.com>
>Assisted-by: LLM
>Signed-off-by: Sang-Hoon Choi <csh0052@gmail.com>
>---
>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(+)
>
>diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
>index 3d6fdbab05e0..456c60b9be17 100644
>--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
>+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_router.c
>@@ -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);
>

Reviewed-by: Ivan Vecera <ivecera@redhat.com>


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] mlxsw: spectrum_router: destroy FIB hash table on bind failure
  2026-10-02 19:47 [PATCH net] mlxsw: spectrum_router: destroy FIB hash table on bind failure Sang-Hoon Choi
  2026-10-03 10:00 ` Ivan Vecera
@ 2026-10-04  7:47 ` Ido Schimmel
  2026-10-06  0:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: Ido Schimmel @ 2026-10-04  7:47 UTC (permalink / raw)
  To: Sang-Hoon Choi; +Cc: Petr Machata, netdev, Jiri Pirko, Changyul Lee

On Fri, Oct 02, 2026 at 07:47:40PM +0000, Sang-Hoon Choi wrote:
> 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.
> 
> Fixes: 2b52ce02e1d1 ("mlxsw: spectrum_router: Remove unnecessary prefix lengths from LPM tree")
> Reported-by: Changyul Lee <lcy8047@gmail.com>
> Assisted-by: LLM
> Signed-off-by: Sang-Hoon Choi <csh0052@gmail.com>

Reviewed-by: Ido Schimmel <idosch@nvidia.com>

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH net] mlxsw: spectrum_router: destroy FIB hash table on bind failure
  2026-10-02 19:47 [PATCH net] mlxsw: spectrum_router: destroy FIB hash table on bind failure Sang-Hoon Choi
  2026-10-03 10:00 ` Ivan Vecera
  2026-10-04  7:47 ` Ido Schimmel
@ 2026-10-06  0:10 ` patchwork-bot+netdevbpf
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-10-06  0:10 UTC (permalink / raw)
  To: Sang-Hoon Choi; +Cc: idosch, petrm, netdev, jiri, lcy8047

Hello:

This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Fri, 02 Oct 2026 19:47:40 +0000 you wrote:
> 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.
> 
> Fixes: 2b52ce02e1d1 ("mlxsw: spectrum_router: Remove unnecessary prefix lengths from LPM tree")
> Reported-by: Changyul Lee <lcy8047@gmail.com>
> Assisted-by: LLM
> Signed-off-by: Sang-Hoon Choi <csh0052@gmail.com>
> 
> [...]

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-10-06  0:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-02 19:47 [PATCH net] mlxsw: spectrum_router: destroy FIB hash table on bind failure Sang-Hoon Choi
2026-10-03 10:00 ` Ivan Vecera
2026-10-04  7:47 ` Ido Schimmel
2026-10-06  0:10 ` patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox