aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEd Swierk <eswierk@arastra.com>2006-09-25 19:25:36 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-25 20:38:36 -0400
commit1cc5f7142eca352109895fe20b1fc6405dd17727 (patch)
tree9c6b4b3204f06317c830457e091ff2c83272ea09
parentbfa0e9a07cd31f3858239dbc93011b82780acf4b (diff)
[PATCH] load_module: no BUG if module_subsys uninitialized
Invoking load_module() before param_sysfs_init() is called crashes in mod_sysfs_setup(), since the kset in module_subsys is not initialized yet. In my case, net-pf-1 is getting modprobed as a result of hotplug trying to create a UNIX socket. Calls to hotplug begin after the topology_init initcall. Another patch for the same symptom (module_subsys-initialize-earlier.patch) moves param_sysfs_init() to the subsys initcalls, but this is still not early enough in the boot process in some cases. In particular, topology_init() causes /sbin/hotplug to run, which requests net-pf-1 (the UNIX socket protocol) which can be compiled as a module. Moving param_sysfs_init() to the postcore initcalls fixes this particular race, but there might well be other cases where a usermodehelper causes a module to load earlier still. The patch makes load_module() return an error rather than crashing the kernel if invoked before module_subsys is initialized. Cc: Mark Huang <mlhuang@cs.princeton.edu> Cc: Greg KH <greg@kroah.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--kernel/module.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/kernel/module.c b/kernel/module.c
index 2a19cd47c046..b7fe6e840963 100644
--- a/kernel/module.c
+++ b/kernel/module.c
@@ -1054,6 +1054,12 @@ static int mod_sysfs_setup(struct module *mod,
1054{ 1054{
1055 int err; 1055 int err;
1056 1056
1057 if (!module_subsys.kset.subsys) {
1058 printk(KERN_ERR "%s: module_subsys not initialized\n",
1059 mod->name);
1060 err = -EINVAL;
1061 goto out;
1062 }
1057 memset(&mod->mkobj.kobj, 0, sizeof(mod->mkobj.kobj)); 1063 memset(&mod->mkobj.kobj, 0, sizeof(mod->mkobj.kobj));
1058 err = kobject_set_name(&mod->mkobj.kobj, "%s", mod->name); 1064 err = kobject_set_name(&mod->mkobj.kobj, "%s", mod->name);
1059 if (err) 1065 if (err)