From: Sang-Hoon Choi <csh0052@gmail.com>
To: Ido Schimmel <idosch@nvidia.com>, Petr Machata <petrm@nvidia.com>
Cc: netdev@vger.kernel.org, Jiri Pirko <jiri@resnulli.us>,
Changyul Lee <lcy8047@gmail.com>
Subject: [PATCH net] mlxsw: spectrum_router: destroy FIB hash table on bind failure
Date: Fri, 02 Oct 2026 19:47:40 +0000 [thread overview]
Message-ID: <20261003.final104.6f67a6ed1c4476b7@gmail.com> (raw)
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);
next reply other threads:[~2026-10-02 19:59 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-02 19:47 Sang-Hoon Choi [this message]
2026-10-03 10:00 ` [PATCH net] mlxsw: spectrum_router: destroy FIB hash table on bind failure Ivan Vecera
2026-10-04 7:47 ` Ido Schimmel
2026-10-06 0:10 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261003.final104.6f67a6ed1c4476b7@gmail.com \
--to=csh0052@gmail.com \
--cc=idosch@nvidia.com \
--cc=jiri@resnulli.us \
--cc=lcy8047@gmail.com \
--cc=netdev@vger.kernel.org \
--cc=petrm@nvidia.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox