]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
librbd: memory leak possible if journal op event failed
authorJason Dillaman <dillaman@redhat.com>
Thu, 23 Jun 2016 13:03:24 +0000 (09:03 -0400)
committerJason Dillaman <dillaman@redhat.com>
Fri, 24 Jun 2016 12:21:37 +0000 (08:21 -0400)
Signed-off-by: Jason Dillaman <dillaman@redhat.com>
src/librbd/journal/Replay.cc

index fbe8890a60b76d2554b6e9477b8f41fa345ba360..02a3a010b5648852d84c98cf256f231c7b75a380 100644 (file)
@@ -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);
   }
 };