浏览代码

modules: fix module waiting for dependent modules' init

Commit c9a3ba55 (module: wait for dependent modules doing init.) didn't quite
work because the waiter holds the module lock, meaning that the state of the
module it's waiting for cannot change.

Fortunately, it's fairly simple to update the state outside the lock and do
the wakeup.

Thanks to Jan Glauber for tracking this down and testing (qdio and qeth).

Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Cc: Jan Glauber <jang@linux.vnet.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Rusty Russell 17 年之前
父节点
当前提交
6c5db22d28
共有 1 个文件被更改,包括 4 次插入3 次删除
  1. 4 3
      kernel/module.c

+ 4 - 3
kernel/module.c

@@ -2179,9 +2179,11 @@ sys_init_module(void __user *umod,
 		return ret;
 		return ret;
 	}
 	}
 
 
-	/* Now it's a first class citizen! */
-	mutex_lock(&module_mutex);
+	/* Now it's a first class citizen!  Wake up anyone waiting for it. */
 	mod->state = MODULE_STATE_LIVE;
 	mod->state = MODULE_STATE_LIVE;
+	wake_up(&module_wq);
+
+	mutex_lock(&module_mutex);
 	/* Drop initial reference. */
 	/* Drop initial reference. */
 	module_put(mod);
 	module_put(mod);
 	unwind_remove_table(mod->unwind_info, 1);
 	unwind_remove_table(mod->unwind_info, 1);
@@ -2190,7 +2192,6 @@ sys_init_module(void __user *umod,
 	mod->init_size = 0;
 	mod->init_size = 0;
 	mod->init_text_size = 0;
 	mod->init_text_size = 0;
 	mutex_unlock(&module_mutex);
 	mutex_unlock(&module_mutex);
-	wake_up(&module_wq);
 
 
 	return 0;
 	return 0;
 }
 }