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 <oro@il.ibm.com>
This commit is contained in:
Or Ozeri 2021-11-25 15:47:54 +02:00
parent 0f61c82d2e
commit 044280dcbe

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