aboutsummaryrefslogtreecommitdiffstats
path: root/net/tls/tls_main.c
diff options
context:
space:
mode:
Diffstat (limited to 'net/tls/tls_main.c')
-rw-r--r--net/tls/tls_main.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/net/tls/tls_main.c b/net/tls/tls_main.c
index cc03e00785c7..74ed1e7af3d9 100644
--- a/net/tls/tls_main.c
+++ b/net/tls/tls_main.c
@@ -248,16 +248,13 @@ static void tls_sk_proto_close(struct sock *sk, long timeout)
248 struct tls_context *ctx = tls_get_ctx(sk); 248 struct tls_context *ctx = tls_get_ctx(sk);
249 long timeo = sock_sndtimeo(sk, 0); 249 long timeo = sock_sndtimeo(sk, 0);
250 void (*sk_proto_close)(struct sock *sk, long timeout); 250 void (*sk_proto_close)(struct sock *sk, long timeout);
251 bool free_ctx = false;
251 252
252 lock_sock(sk); 253 lock_sock(sk);
253 sk_proto_close = ctx->sk_proto_close; 254 sk_proto_close = ctx->sk_proto_close;
254 255
255 if (ctx->conf == TLS_HW_RECORD) 256 if (ctx->conf == TLS_BASE || ctx->conf == TLS_HW_RECORD) {
256 goto skip_tx_cleanup; 257 free_ctx = true;
257
258 if (ctx->conf == TLS_BASE) {
259 kfree(ctx);
260 ctx = NULL;
261 goto skip_tx_cleanup; 258 goto skip_tx_cleanup;
262 } 259 }
263 260
@@ -294,7 +291,7 @@ skip_tx_cleanup:
294 /* free ctx for TLS_HW_RECORD, used by tcp_set_state 291 /* free ctx for TLS_HW_RECORD, used by tcp_set_state
295 * for sk->sk_prot->unhash [tls_hw_unhash] 292 * for sk->sk_prot->unhash [tls_hw_unhash]
296 */ 293 */
297 if (ctx && ctx->conf == TLS_HW_RECORD) 294 if (free_ctx)
298 kfree(ctx); 295 kfree(ctx);
299} 296}
300 297