Commit 6494a93d authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman Committed by Rusty Russell

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 <rusty@rustcorp.com.au>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarRusty Russell <rusty@rustcorp.com.au>
parent 0aa5bd52
...@@ -1230,6 +1230,7 @@ void module_remove_modinfo_attrs(struct module *mod) ...@@ -1230,6 +1230,7 @@ void module_remove_modinfo_attrs(struct module *mod)
int mod_sysfs_init(struct module *mod) int mod_sysfs_init(struct module *mod)
{ {
int err; int err;
struct kobject *kobj;
if (!module_sysfs_initialized) { if (!module_sysfs_initialized) {
printk(KERN_ERR "%s: module sysfs not initialized\n", printk(KERN_ERR "%s: module sysfs not initialized\n",
...@@ -1237,6 +1238,15 @@ int mod_sysfs_init(struct module *mod) ...@@ -1237,6 +1238,15 @@ int mod_sysfs_init(struct module *mod)
err = -EINVAL; err = -EINVAL;
goto out; 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; mod->mkobj.mod = mod;
memset(&mod->mkobj.kobj, 0, sizeof(mod->mkobj.kobj)); memset(&mod->mkobj.kobj, 0, sizeof(mod->mkobj.kobj));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment