net/smc: Do not re-initialize smc hashtables
Subsystems (5)
PATCH 1/1 net/smc: Do not re-initialize smc hashtables
INIT_HLIST_HEAD(&smc_v*_hashinfo.ht) are called after smc_nl_init(), proto_register() and sock_register(). This can lead to smc_v*_hashinfo.ht being reset even though hash entries already exist and are being used, possibly resulting in a corrupted list.
Remove unnecessary and dangerous re-initialisation of smc_v*_hashinfo.ht in smc_init(); it is implicitly initialised to zero anyhow. Add HLIST_HEAD_INIT to the definitions for clarity.
--- net/smc/af_smc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
net/smc/af_smc.c +2 -2
@@ -188,10 +188,12 @@ static bool smc_hs_congested(const struct sock *sk)struct smc_hashinfo smc_v4_hashinfo = { .lock =__RW_LOCK_UNLOCKED (smc_v4_hashinfo.lock), + .ht =HLIST_HEAD_INIT , };struct smc_hashinfo smc_v6_hashinfo = { .lock =__RW_LOCK_UNLOCKED (smc_v6_hashinfo.lock), + .ht =HLIST_HEAD_INIT , };int smc_hash_sk (struct sock *sk)
@@ -3517,8 +3519,6 @@ static int __init smc_init(void)pr_err ("%s: sock_register fails with %d\n" , __func__, rc); goto out_proto6; } -INIT_HLIST_HEAD (&smc_v4_hashinfo.ht); -INIT_HLIST_HEAD (&smc_v6_hashinfo.ht); rc =smc_ib_register_client ();if (rc) {
Signature · 1 line
2.51.0
This patch was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:
Hello:
This patch was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:
Quoted 10 lines · On Thu, 21 May 2026 16:56:39 +0200 you wrote:
INIT_HLIST_HEAD(&smc_v*_hashinfo.ht)are called aftersmc_nl_init(),proto_register()andsock_register(). This can lead to smc_v*_hashinfo.ht being reset even though hash entries already exist and are being used, possibly resulting in a corrupted list.Remove unnecessary and dangerous re-initialisation of smc_v*_hashinfo.ht in
smc_init(); it is implicitly initialised to zero anyhow. AddHLIST_HEAD_INITto the definitions for clarity.[...]
Here is the summary with links:
- [net] net/smc: Do not re-initialize smc hashtables
https://git.kernel.org/netdev/net/c/9e4389b00387
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html