From 044280dcbe808d76cb2c97e1457685d76e8c869a Mon Sep 17 00:00:00 2001 From: Or Ozeri Date: Thu, 25 Nov 2021 15:47:54 +0200 Subject: [PATCH] librbd/crypto: fix memory leak in ShutDownCryptoRequest If crypto object dispatch does not exist, a context pointer is leaked. This commit fixes this issue. Signed-off-by: Or Ozeri --- src/librbd/crypto/ShutDownCryptoRequest.cc | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/librbd/crypto/ShutDownCryptoRequest.cc b/src/librbd/crypto/ShutDownCryptoRequest.cc index dad6e2fc192df..bc3e47bb11c3f 100644 --- a/src/librbd/crypto/ShutDownCryptoRequest.cc +++ b/src/librbd/crypto/ShutDownCryptoRequest.cc @@ -39,15 +39,16 @@ void ShutDownCryptoRequest::send() { template void ShutDownCryptoRequest::shut_down_object_dispatch() { - auto ctx = create_context_callback< - ShutDownCryptoRequest, - &ShutDownCryptoRequest::handle_shut_down_object_dispatch>(this); if (!m_image_ctx->io_object_dispatcher->exists( io::OBJECT_DISPATCH_LAYER_CRYPTO)) { finish(0); return; } + auto ctx = create_context_callback< + ShutDownCryptoRequest, + &ShutDownCryptoRequest::handle_shut_down_object_dispatch>(this); + m_image_ctx->io_object_dispatcher->shut_down_dispatch( io::OBJECT_DISPATCH_LAYER_CRYPTO, ctx); } -- 2.39.5