[RFC mptcp-next v2] Squash to "tls: add ops in tls_context"

Geliang Tang
2026-01-13T08:07:23Z

From: Geliang Tang <tanggeliang@kylinos.cn>

Oops, sorry. spin_lock(&tls_prot_ops_lock) shouldn't be called after
write_lock_bh(&sk->sk_callback_lock); otherwise, a deadlock occurs.

When calling tls_prot_ops_find() here, it's unnecessary to hold
tls_prot_ops_lock; holding sk->sk_callback_lock is sufficient.

Based-on: <cover.1768284047.git.tanggeliang@kylinos.cn>

Signed-off-by: Geliang Tang <tanggeliang@kylinos.cn>
---
v2:
- do not hold tls_prot_ops_lock in tls_init().
---
net/tls/tls_main.c | 2 --
1 file changed, 2 deletions(-)

diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index 75e01f2dde26..1051cb53bc5a 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -1097,9 +1097,7 @@ static int tls_init(struct sock *sk)
ctx->tx_conf = TLS_BASE;
ctx->rx_conf = TLS_BASE;
ctx->tx_max_payload_len = TLS_MAX_PAYLOAD_SIZE;
- spin_lock(&tls_prot_ops_lock);
ctx->ops = tls_prot_ops_find(sk->sk_protocol);
- spin_unlock(&tls_prot_ops_lock);
if (!ctx->ops) {
rc = -EINVAL;
goto out;
--
2.51.0