From 181a9a043b5424f2e6451297bbc27b196fe88475 Mon Sep 17 00:00:00 2001 From: Zongxun Wang Date: Thu, 3 Apr 2014 14:46:45 -0700 Subject: [PATCH] ocfs2: fix null pointer dereference when access dlm_state before launching dlm thread When mounting an ocfs2 volume, it will firstly generate a file /sys/kernel/debug/o2dlm//dlm_state, and then launch the dlm thread. So the following situation will cause a null pointer dereference. dlm_debug_init -> access file dlm_state which will call dlm_state_print -> dlm_launch_thread Move dlm_debug_init after dlm_launch_thread and dlm_launch_recovery_thread can fix this issue. Signed-off-by: Zongxun Wang Signed-off-by: Joseph Qi Cc: Mark Fasheh Cc: Joel Becker Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds --- fs/ocfs2/dlm/dlmdomain.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index 33660a4a52fa..1307a8cff8db 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c @@ -1877,12 +1877,6 @@ static int dlm_join_domain(struct dlm_ctxt *dlm) goto bail; } - status = dlm_debug_init(dlm); - if (status < 0) { - mlog_errno(status); - goto bail; - } - status = dlm_launch_thread(dlm); if (status < 0) { mlog_errno(status); @@ -1895,6 +1889,12 @@ static int dlm_join_domain(struct dlm_ctxt *dlm) goto bail; } + status = dlm_debug_init(dlm); + if (status < 0) { + mlog_errno(status); + goto bail; + } + dlm->dlm_worker = create_singlethread_workqueue("dlm_wq"); if (!dlm->dlm_worker) { status = -ENOMEM;