]> git-server-git.apps.pok.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)
committerIlya Dryomov <idryomov@gmail.com>
Sun, 13 Feb 2022 15:49:58 +0000 (16:49 +0100)
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>
(cherry picked from commit 044280dcbe808d76cb2c97e1457685d76e8c869a)

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);
 }