ocfs2: Proper cleanup in case of error in ocfs2_register_hb_callbacks()
[firefly-linux-kernel-4.4.55.git] / fs / ocfs2 / heartbeat.c
index 8fc52d6d0ce7827a75f40f40986f9ea8ef07b752..b25ef63781baafa695e64b1660d12e6d1edf2cb5 100644 (file)
@@ -164,8 +164,10 @@ int ocfs2_register_hb_callbacks(struct ocfs2_super *osb)
        }
 
        status = o2hb_register_callback(&osb->osb_hb_up);
-       if (status < 0)
+       if (status < 0) {
                mlog_errno(status);
+               o2hb_unregister_callback(&osb->osb_hb_down);
+       }
 
 bail:
        return status;
@@ -173,18 +175,11 @@ bail:
 
 void ocfs2_clear_hb_callbacks(struct ocfs2_super *osb)
 {
-       int status;
-
        if (ocfs2_mount_local(osb))
                return;
 
-       status = o2hb_unregister_callback(&osb->osb_hb_down);
-       if (status < 0)
-               mlog_errno(status);
-
-       status = o2hb_unregister_callback(&osb->osb_hb_up);
-       if (status < 0)
-               mlog_errno(status);
+       o2hb_unregister_callback(&osb->osb_hb_down);
+       o2hb_unregister_callback(&osb->osb_hb_up);
 }
 
 void ocfs2_stop_heartbeat(struct ocfs2_super *osb)