Skip to content

Commit 550842c

Browse files
Heming Zhaoakpm00
authored andcommitted
ocfs2: fix freeing uninitialized resource on ocfs2_dlm_shutdown
After commit 0737e01 ("ocfs2: ocfs2_mount_volume does cleanup job before return error"), any procedure after ocfs2_dlm_init() fails will trigger crash when calling ocfs2_dlm_shutdown(). ie: On local mount mode, no dlm resource is initialized. If ocfs2_mount_volume() fails in ocfs2_find_slot(), error handling will call ocfs2_dlm_shutdown(), then does dlm resource cleanup job, which will trigger kernel crash. This solution should bypass uninitialized resources in ocfs2_dlm_shutdown(). Link: https://lkml.kernel.org/r/20220815085754.20417-1-heming.zhao@suse.com Fixes: 0737e01 ("ocfs2: ocfs2_mount_volume does cleanup job before return error") Signed-off-by: Heming Zhao <heming.zhao@suse.com> Reviewed-by: Joseph Qi <joseph.qi@linux.alibaba.com> Cc: Mark Fasheh <mark@fasheh.com> Cc: Joel Becker <jlbec@evilplan.org> Cc: Junxiao Bi <junxiao.bi@oracle.com> Cc: Changwei Ge <gechangwei@live.cn> Cc: Gang He <ghe@suse.com> Cc: Jun Piao <piaojun@huawei.com> Cc: <stable@vger.kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
1 parent dbb16df commit 550842c

File tree

2 files changed

+6
-5
lines changed

2 files changed

+6
-5
lines changed

fs/ocfs2/dlmglue.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3403,10 +3403,12 @@ void ocfs2_dlm_shutdown(struct ocfs2_super *osb,
34033403
ocfs2_lock_res_free(&osb->osb_nfs_sync_lockres);
34043404
ocfs2_lock_res_free(&osb->osb_orphan_scan.os_lockres);
34053405

3406-
ocfs2_cluster_disconnect(osb->cconn, hangup_pending);
3407-
osb->cconn = NULL;
3406+
if (osb->cconn) {
3407+
ocfs2_cluster_disconnect(osb->cconn, hangup_pending);
3408+
osb->cconn = NULL;
34083409

3409-
ocfs2_dlm_shutdown_debug(osb);
3410+
ocfs2_dlm_shutdown_debug(osb);
3411+
}
34103412
}
34113413

34123414
static int ocfs2_drop_lock(struct ocfs2_super *osb,

fs/ocfs2/super.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1914,8 +1914,7 @@ static void ocfs2_dismount_volume(struct super_block *sb, int mnt_err)
19141914
!ocfs2_is_hard_readonly(osb))
19151915
hangup_needed = 1;
19161916

1917-
if (osb->cconn)
1918-
ocfs2_dlm_shutdown(osb, hangup_needed);
1917+
ocfs2_dlm_shutdown(osb, hangup_needed);
19191918

19201919
ocfs2_blockcheck_stats_debugfs_remove(&osb->osb_ecc_stats);
19211920
debugfs_remove_recursive(osb->osb_debug_root);

0 commit comments

Comments
 (0)