Skip to content

Commit

Permalink
Module: check to see if we have a built in module with the same name
Browse files Browse the repository at this point in the history
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: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
Greg Kroah-Hartman authored and Rusty Russell committed Jan 29, 2008
1 parent 0aa5bd5 commit 6494a93
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -1230,13 +1230,23 @@ 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",
mod->name);
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));
Expand Down

0 comments on commit 6494a93

Please sign in to comment.