Skip to content

Commit 0834ced

Browse files
yuliao0214kuba-moo
authored andcommitted
net/tls: Fix memory leak in tls_enc_skb() and tls_sw_fallback_init()
'aead_req' and 'aead_send' is allocated but not freed in default switch case. This commit fixes the potential memory leak by freeing them under the situation. Note that the default cases here should never be reached as they'd mean we allowed offloading an unsupported algorithm. Fixes: ea7a9d8 ("net/tls: Use cipher sizes structs") Signed-off-by: Yu Liao <[email protected]> Reviewed-by: Gal Pressman <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 7771168 commit 0834ced

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

net/tls/tls_device_fallback.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ static struct sk_buff *tls_enc_skb(struct tls_context *tls_ctx,
346346
salt = tls_ctx->crypto_send.aes_gcm_256.salt;
347347
break;
348348
default:
349-
return NULL;
349+
goto free_req;
350350
}
351351
cipher_sz = &tls_cipher_size_desc[tls_ctx->crypto_send.info.cipher_type];
352352
buf_len = cipher_sz->salt + cipher_sz->iv + TLS_AAD_SPACE_SIZE +
@@ -492,7 +492,8 @@ int tls_sw_fallback_init(struct sock *sk,
492492
key = ((struct tls12_crypto_info_aes_gcm_256 *)crypto_info)->key;
493493
break;
494494
default:
495-
return -EINVAL;
495+
rc = -EINVAL;
496+
goto free_aead;
496497
}
497498
cipher_sz = &tls_cipher_size_desc[crypto_info->cipher_type];
498499

0 commit comments

Comments
 (0)