From: Greg Kroah-Hartman Date: Sun, 27 Jan 2008 18:29:20 +0000 (-0800) Subject: Module: check to see if we have a built in module with the same name X-Git-Tag: v2.6.25-rc1~1137^2~2 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=123ca9575b1f5342c05a4b84d6af8ba7587c2981;p=linux-2.6 Module: check to see if we have a built in module with the same name When trying to load a module with the same name as a built-in one, a scary kobject backtrace comes up. Prevent that from checking for this condition and warning the user as to what exactly is going on. Cc: Rusty Russell Cc: Linus Torvalds Cc: Andrew Morton Signed-off-by: Greg Kroah-Hartman --- diff --git a/kernel/module.c b/kernel/module.c index 1bb4c5e0d5..76ddc85a42 100644 --- a/kernel/module.c +++ b/kernel/module.c @@ -1214,6 +1214,7 @@ void module_remove_modinfo_attrs(struct module *mod) int mod_sysfs_init(struct module *mod) { int err; + struct kobject *kobj; if (!module_sysfs_initialized) { printk(KERN_ERR "%s: module sysfs not initialized\n", @@ -1221,6 +1222,15 @@ int mod_sysfs_init(struct module *mod) err = -EINVAL; goto out; } + + kobj = kset_find_obj(module_kset, mod->name); + if (kobj) { + printk(KERN_ERR "%s: module is already loaded\n", mod->name); + kobject_put(kobj); + err = -EINVAL; + goto out; + } + mod->mkobj.mod = mod; memset(&mod->mkobj.kobj, 0, sizeof(mod->mkobj.kobj));