]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
librbd/crypto: fix memory leak in ShutDownCryptoRequest
authorOr Ozeri <oro@il.ibm.com>
Thu, 25 Nov 2021 13:47:54 +0000 (15:47 +0200)
committerOr Ozeri <oro@il.ibm.com>
Sun, 28 Nov 2021 11:06:34 +0000 (13:06 +0200)
If crypto object dispatch does not exist, a context pointer is leaked.
This commit fixes this issue.

Signed-off-by: Or Ozeri <oro@il.ibm.com>
src/librbd/crypto/ShutDownCryptoRequest.cc

index dad6e2fc192df55733494b1de0cde018064c9ff4..bc3e47bb11c3f34276000651454734e66a915af4 100644 (file)
@@ -39,15 +39,16 @@ void ShutDownCryptoRequest<I>::send() {
 
 template <typename I>
 void ShutDownCryptoRequest<I>::shut_down_object_dispatch() {
-   auto ctx = create_context_callback<
-          ShutDownCryptoRequest<I>,
-          &ShutDownCryptoRequest<I>::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<I>,
+          &ShutDownCryptoRequest<I>::handle_shut_down_object_dispatch>(this);
+
   m_image_ctx->io_object_dispatcher->shut_down_dispatch(
           io::OBJECT_DISPATCH_LAYER_CRYPTO, ctx);
 }