From: Jason Dillaman Date: Thu, 23 Jun 2016 13:03:24 +0000 (-0400) Subject: librbd: memory leak possible if journal op event failed X-Git-Tag: v11.0.0~44^2 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=f5069750849c2c43caa4bff766301169a4bfc6ca;p=ceph-ci.git librbd: memory leak possible if journal op event failed Signed-off-by: Jason Dillaman --- diff --git a/src/librbd/journal/Replay.cc b/src/librbd/journal/Replay.cc index fbe8890a60b..02a3a010b56 100644 --- a/src/librbd/journal/Replay.cc +++ b/src/librbd/journal/Replay.cc @@ -112,24 +112,29 @@ struct C_RefreshIfRequired : public Context { C_RefreshIfRequired(I &image_ctx, Context *on_finish) : image_ctx(image_ctx), on_finish(on_finish) { } + virtual ~C_RefreshIfRequired() { + delete on_finish; + } virtual void finish(int r) override { CephContext *cct = image_ctx.cct; + Context *ctx = on_finish; + on_finish = nullptr; if (r < 0) { lderr(cct) << "C_RefreshIfRequired: " << __func__ << ": r=" << r << dendl; - image_ctx.op_work_queue->queue(on_finish, r); + image_ctx.op_work_queue->queue(ctx, r); return; } if (image_ctx.state->is_refresh_required()) { ldout(cct, 20) << "C_RefreshIfRequired: " << __func__ << ": " << "refresh required" << dendl; - image_ctx.state->refresh(on_finish); + image_ctx.state->refresh(ctx); return; } - image_ctx.op_work_queue->queue(on_finish, 0); + image_ctx.op_work_queue->queue(ctx, 0); } };