From: Steven Luong Date: Fri, 18 Nov 2022 22:17:42 +0000 (-0800) Subject: tls: memory leak due to missing call to vnet_crypto_key_del X-Git-Tag: v23.06-rc0~121 X-Git-Url: https://gerrit.fd.io/r/gitweb?a=commitdiff_plain;h=dfd169816e4d63fa2f586bbad5820eb80f483733;p=vpp.git tls: memory leak due to missing call to vnet_crypto_key_del We add the crypto key to the vnet crypto library via vnet_crypto_key_add. However, when the session is disconnected, we don't call vnet_crypto_key_del and the memory is leaked in vnet_crypto library as well as in pico tls key store. It seems dispose crypto is the appropriate place to add vnet_crypto_key_del. Type: fix Signed-off-by: Steven Luong Change-Id: If6d1266baf686fefe5bb81330ce60b35c8ff574e --- diff --git a/src/plugins/tlspicotls/pico_vpp_crypto.c b/src/plugins/tlspicotls/pico_vpp_crypto.c index f3514d07b23..24af935fc9c 100644 --- a/src/plugins/tlspicotls/pico_vpp_crypto.c +++ b/src/plugins/tlspicotls/pico_vpp_crypto.c @@ -197,7 +197,12 @@ ptls_vpp_crypto_aead_encrypt_final (ptls_aead_context_t * _ctx, void *_output) static void ptls_vpp_crypto_aead_dispose_crypto (ptls_aead_context_t * _ctx) { - /* Do nothing */ + vlib_main_t *vm = vlib_get_main (); + struct vpp_aead_context_t *ctx = (struct vpp_aead_context_t *) _ctx; + + clib_rwlock_writer_lock (&picotls_main.crypto_keys_rw_lock); + vnet_crypto_key_del (vm, ctx->key_index); + clib_rwlock_writer_unlock (&picotls_main.crypto_keys_rw_lock); } static int